During the recent QGIS hackfest in Poland, we spent some time discussing the use of GIT and I spent a bit of time to learn the basics of using GIT. One thing about GIT that is different for users like myself coming from an SVN background is the way that creating and applying patches is done. Typically under svn I would do something like this to create a patch:
svn diff > foo.diff
And then to apply that same patch I would do:
patch -p0 < foo.diff
Which is all quite simple. Git’s process is a little different. Here is my workflow for creating a patch:
- Create a branch (GIT seems to encourage you to work in branches and to branch often)
- Checkout your branch
- Work and change things in your branch
- Commit your work to your branch
- Generate a patch as a diff between your branch and master
- Submit your patch
- Apply your patch
So here is a simple session that does the above:
git branch patch-testing git checkout patch-testing ( do some work in that branch now) git commit -m "Important changes" -a git format-patch master
After you are done with that, Git will have created a nice little diff for you. To apply the patch to another checkout do:
git apply foo.path
Then commit and push your changes to the origin repository.