tags:

views:

82

answers:

4

Hi,

I have 2 git local repository both pointing to the same remote repository. In 1 git repository, if I do 'git format-patch 1', how can i apply that patch to the other repository?

Thank you.

+1  A: 
git apply name-of-file.patch
Jeff Dallien
+1  A: 

Or, if you're kicking it old school:

cd /path/to/other/repository
patch -p1 < 0001-whatever.patch
Dominic Cooney
+5  A: 

Note: You could can first preview what your patch will do:

First the stats:

git apply --stat a_file.patch

Then a dry run to detect errors:

git apply --check a_file.patch

Finally, you can use git am to apply your patch: it allows you to sign off an applied patch.
This can be useful for later reference.

git am --signoff < a_file.patch 

See an example in this article:

In you git log, you’ll find that the commit messages contain a “Signed-off-by” tag. This tag will be read by Github and others to provide useful info about how the commit ended up in the code.

alt text

VonC
+1  A: 

If you want to apply it as a commit, use git am

Jakub Narębski