Skip to content

Instantly share code, notes, and snippets.

@miebach
Forked from idbrii/example.sh
Created March 2, 2011 02:39
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 miebach/850371 to your computer and use it in GitHub Desktop.
Save miebach/850371 to your computer and use it in GitHub Desktop.
#! /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 commit -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 commit -am "new recruits"
echo Add 'b' as a remote to 'a'
cd ../a
git remote add b ../b
git fetch b
git branch
git checkout b/master
git checkout -t b/z
git branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment