public
Last active

How to track a parent branch?

  • Download Gist
track-parent
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 
 
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
 
 
 
 
 
 
 

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.