Reputation: 5412
I am looking for the command for creating a patch from the last commit made.
My workflow sometimes looks like this:
vi some.txt
git add some.txt
git commit -m "some change"
Now I just want to write:
git create-patch-from-last-commit-to-file SOME-PATCH0001.patch
What should I put there instead of create-patch-from-last-commit-to-file
?
Upvotes: 243
Views: 250130
Reputation: 67802
In general,
git format-patch -n HEAD^
(check help for the many options), although it's really for mailing them. For a single commit just
git show HEAD > some-patch0001.patch
will give you a useable patch.
Upvotes: 372
Reputation: 399
For example if you are pushing code in branch "branch_name" on Github. Every commit on this branch will have separate url. Click on latest commit.
Upvotes: 1
Reputation: 3636
Taking from @Useless answer, you can also use the general form with no parameters for the last commit and put it into a file with:
git format-patch HEAD^ --stdout > patchfile.patch
Or, being cleaner for windows users when carets have to be escaped by doubling them:
git format-patch HEAD~1 --stdout > patchfile.patch
Upvotes: 74
Reputation: 4869
another way, if have the commit id of that particular commit, you can use,
git format-patch -1 {commit-id}
Upvotes: 35