JuJoDi
JuJoDi

Reputation: 14955

How to apply a diff to source code?

Someone sent me the output of a diff of my remote and their local. My local is a clone of the remote with no changes. What is the best way to apply the diff to my local without manually going through it and making each change?

diff --git a/path b/path

Upvotes: 1

Views: 413

Answers (2)

nsfyn55
nsfyn55

Reputation: 15353

It depends on your workflow you can use git apply to apply a properly formatted patch. Alternatively you could have the other party push to a shared branch git push origin <branch> and you could pull their branch down and merge/rebase the changes. Both of these are functionally equivalent, but the second option sports a little recordkeeping regarding your code sharing arrangement.

Upvotes: 1

larsks
larsks

Reputation: 311238

The git apply command will take a patch and apply it to your local directory. There is some good discussion here, and of course also the git-apply documentation.

Upvotes: 5

Related Questions