Skip to content

Instantly share code, notes, and snippets.

@idbrii
Created March 1, 2011 18:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save idbrii/849624 to your computer and use it in GitHub Desktop.
Save idbrii/849624 to your computer and use it in GitHub Desktop.
example for How to 'git remote add' and track a branch in the same filesystem
#! /bin/sh
# Script to provide answer for question:
# http://stackoverflow.com/questions/5149872/how-to-git-remote-add-and-track-a-branch-in-the-same-filesystem
echo create origin
mkdir origin
cd origin/
git init --bare
cd ..
echo clone 'a' and add some content
git clone origin/ a
cd a
echo hi there > hello
git add hello
git ci -m'first commit'
git push origin master
echo clone 'b' and add more content on new branch
cd ..
git clone origin/ b
cd b
git checkout -b z
echo new guy reporting in >> hello
git ci -am "new recruits"
echo Add 'b' as a remote to 'a'
cd ../a
git remote add b ../b
git fetch b
git br
git checkout b/master
git checkout -t b/z
git br
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment