PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 3## Bundles
 4Bundles are binary compressed archives that contain a series of commits. This format can be easily transmitted via email or USB stick.
 5
 6### Creating a bundle
 7Create a bundle from a range of commit treeish
 8
 9    git bundle create catchup.bundle HEAD~8..HEAD
10
11Create a bundle from a range of time
12
13    git bundle create catchup.bundle --since=10.days master
14
15Create a bundle from an entire branch
16
17    git bundle create catchup.bundle master
18
19### Visualize the Bundle
20Show contents of a bundle
21
22    git ls-remote catchup.bundle
23
24Or just the HEADs
25
26    git bundle list-heads catchup.bundle
27    
28## Verify the Bundle
29
30    git bundle verify catchup.bundle
31
32
33### Retrieve the Bundle Contents
34Pull 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.
35
36    git fetch catchup.bundle master:catchupmaster
37    
38Or start a new repo named `temprepo` via `clone` with the contents of the bundle put into the `master` branch
39
40    git clone catchup.bundle -b master temprepo
41    
42### Merge in the Remote Contents
43
44    git merge catchupmaster master
45
46### Reference
47[ProGit section on `git bundle`](http://progit.org/2010/03/10/bundles.html)
48
49
50## Patching
51
52### Build the Patch
53Build an email that contains the patch
54
55    git email-patch
56    
57or 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
58
59    git format-patch master
60
61or reroute it all to a unified file
62
63    git format-patch master --stdout > myfix.patch
64
65### Visualize the Patch
66To view the contents of the patch before applying it
67
68    git apply --stat myfix.patch
69    
70Test the patch application for conflicts
71
72    git apply --check myfix.patch
73    
74
75# Apply a Patch
76
77    git apply myfix.patch
78    
79or using apply-mailbox to apply a series of patches
80
81    git am -3 myfix.patch
82    
83and if any conflicts are encountered, to continue the process
84
85    git am --resolved
86    
87or to sign off on the patch using your credentials
88
89    git am --signoff