Open main menu

Changes

Git patch

446 bytes added, 15:02, 15 October 2015
Forced creation of a TOC - this will improve the formatting on the main page 'Did you know...' section.
__TOC__
 
== Patches ==
See [http://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/ this very nice post!]
git checkout -b fix
In the new fix branch you can hack whatever you need to fix. Write tests, update code etc. etc.<br> # To only add updated files to commit stage git add -u # To make a commit git commit -m "my commit message"
When you’re satisfied with all you changes, it’s time to create your patch. We assume you made a few commits in the fix branch and did not yet merge it back in to the master branch.
Check you changes git log git log --pretty=oneline -35
=== Create patches ===
Now create your patch, comparing to the master branch
git format-patch master --stdout > ignore-if-in-upstreamNow tar and gunzip the files tar -cvzf fix.patch.tar.gz 00*.patch rm 00*.patchIf you need to unpack (ungzip, unarchive) a tar.gz file tar -xzf fix.patch.tar.gz
Normally, git would create a separate patch file for each commit, but that’s not what we want. All we need is a single patch file. This will create a new file fix.patch with all changes from the current branch (fix) against master.
 
Create one patch file, comparing to the master branch
git format-patch master --stdout --ignore-if-in-upstream > fix.patch
Now, you have a patch for the fix you wrote. [[Bugs_and_development_wishes | Send it to the maintainer of the project.]]
Next, you’re interested in how troublesome the patch is going to be. Git allows you to test the patch before you actually apply it.
git checkout master
git apply --check fix.patch
If you don’t get any errors, the patch can be applied cleanly. <br>
Trusted, Bureaucrats
4,228

edits