Skip to content

Instantly share code, notes, and snippets.

@snijsure
Created March 27, 2012 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snijsure/2218449 to your computer and use it in GitHub Desktop.
Save snijsure/2218449 to your computer and use it in GitHub Desktop.
How to track a parent branch?
1. I have setup a git repo called parent.git using
git init --bare
2. Added some files to this parent.git , commited those files and pushed the changes.
3. Now I created a clone of parent.git called trackparent.git as, intent is that trackparent repo will closely track the changes to parent git
git clone --bare --shared ssh://gitserver/opt/git/parent.git
4. Now say users John and Matt are supposed to work off of trackparent.git and make their changes and push them upstream to trackparent.git, this all works great.
5. Now lets say new files get put into or existing stuff changes in parent.git repository.
6. Now in trackparent.git you do
git remote update
This will update your FETCH_HEAD.
You create branch with this FETCH_HEAD's sha1 on trackparent.git as
git branch -f newbranch sha1-shown-in-FETCH_HEAD
7. Now in workspace where you have trackparent.git "checked-out" do
git pull origin newbranch
you should now see changes that went into parent.git in branch newbranch.
Now git push origin to push these changes..
8. Now in workspace that had clones trackparent do
git checkout origin newbranch
Now you should see changes to trackparent via the parent.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment