My general approach is to have two branches, upstream
and master
. Create your repository (which will start you in the master
branch), check in the latest copy of the upstream code that you use, and then create the upsteram
branch with git branch upstream
. Also, create a tag indicating which upstream version you have imported, such as git tag wordpress-1.0
. I usually use lightweight tags for this (ones without any annotations, just basically a pointer to a revision).
[wordpress-1.0] Key: [tag]
v branch
* <- upstream * commit
^- master
Now, while you're still in the master
branch, copy your changes in and check those in. You now have two branches, upstream
which contains the pristine upstream source, and master
which contains your changes, with history showing which changes you have made to upstream
.
[wordpress-1.0]
v
* <- upstream
\
+--* <- master
Make all of your modifications in the master
branch.
[wordpress-1.0]
v
* <- upstream
\
+--*--*--* <- master
When a new version of the upstream code comes along, check out your upstream
branch (git checkout upstream
), clear out everything but the .git
directory, and copy in the new upstream version. Use git add -A
to stage all of the changes in the upstream version, commit it, and tag it.
[wordpress-1.0]
| [wordpress-1.1]
v v
*--* <- upstream
\
+--*--*--* <- master
Now, check out master
, and merge in your upstream changes. At this point, you can choose how to merge, such as taking the new upstream version, taking your version, or taking merged changes, just like you do in a normal merge.
[wordpress-1.0]
| [wordpress-1.1]
v v
*--*--------+ <- upstream
\ \
+--*--*--*--* <- master
So, all of your changes happen on master
, and all upstream versions are committed exactly as is to upstream
. That will let you see most easily exactly how your code differs from the upstream version, it will help keep track of which changes you've already merged with the upstream version, and so on.
[wordpress-1.0]
| [wordpress-1.1]
| | [wordpress-2.0]
v v v
*--*--------+--*-+ <- upstream
\ \ \
+--*--*--*--*----*--* <- master
Hope this helps, let me know if you have any further questions.