/workbook/markdown/15-Transporting_Changes-Patches_and_Bundles.md

http://github.com/matthewmccullough/git-workshop · Markdown · 89 lines · 47 code · 42 blank · 0 comment · 0 complexity · f0b9142b34c2f947f2183ab3e362511c MD5 · raw file

  1. # Transporting Changes
  2. ## Bundles
  3. Bundles are binary compressed archives that contain a series of commits. This format can be easily transmitted via email or USB stick.
  4. ### Creating a bundle
  5. Create a bundle from a range of commit treeish
  6. git bundle create catchup.bundle HEAD~8..HEAD
  7. Create a bundle from a range of time
  8. git bundle create catchup.bundle --since=10.days master
  9. Create a bundle from an entire branch
  10. git bundle create catchup.bundle master
  11. ### Visualize the Bundle
  12. Show contents of a bundle
  13. git ls-remote catchup.bundle
  14. Or just the HEADs
  15. git bundle list-heads catchup.bundle
  16. ## Verify the Bundle
  17. git bundle verify catchup.bundle
  18. ### Retrieve the Bundle Contents
  19. Pull in the blobs from a bundle as if they were a remote, but don't merge them. We'll retrieve them to a new local branch that represents the bundle.
  20. git fetch catchup.bundle master:catchupmaster
  21. Or start a new repo named `temprepo` via `clone` with the contents of the bundle put into the `master` branch
  22. git clone catchup.bundle -b master temprepo
  23. ### Merge in the Remote Contents
  24. git merge catchupmaster master
  25. ### Reference
  26. [ProGit section on `git bundle`](http://progit.org/2010/03/10/bundles.html)
  27. ## Patching
  28. ### Build the Patch
  29. Build an email that contains the patch
  30. git email-patch
  31. or to [generate a patch file for every file on the current branch](http://book.git-scm.com/5_git_and_email.html) that differs from the master branch
  32. git format-patch master
  33. or reroute it all to a unified file
  34. git format-patch master --stdout > myfix.patch
  35. ### Visualize the Patch
  36. To view the contents of the patch before applying it
  37. git apply --stat myfix.patch
  38. Test the patch application for conflicts
  39. git apply --check myfix.patch
  40. # Apply a Patch
  41. git apply myfix.patch
  42. or using apply-mailbox to apply a series of patches
  43. git am -3 myfix.patch
  44. and if any conflicts are encountered, to continue the process
  45. git am --resolved
  46. or to sign off on the patch using your credentials
  47. git am --signoff