Keeping track of git repos with your changes on top

This will explain, how you can keep your own changes on top of somebody elses git-repository. We will utilize git rebase for this.

Here i'll use a bogus project which does not exist, but you can paraphrase from it.

First you clone the repository:
git clone git@github.com:foobar/baz.git

After that you change into the repository:
cd baz/

Now we create our own branch which tracks master:
git branch -t mybranch

Since we don't want to modify master, we check out the new branch:
git checkout mybranch

And since it helps me, i often remove the local master-branch:
git branch -D master

Now whenever you make changes, you simply commit them to your mybranch branch. When you're done and your upstream has released a new version, you simply rebase like this:
git rebase origin/master

Conflicts

If there are conflicts, it will ask you to resolve them manually if it is not able to do so by itself. If this happens, simply edit the file so that the conflict is resolved and add it with git:
git add conflicted/file.c

When you're done editing, simply run:
git rebase --continue

Saving your changes to your own Repository

I find it useful to save my changes somewhere else than my workstation, not only for backup-purpose, but more or less access control, if i ever have to team up.

git remote add mygit git@mygit:myrepo.git

and start pushing to it

git push mygit +mybranch

Hope you find it useful.

Cheers!

Flattr me!

Tell your friends!