Skip to content

Instantly share code, notes, and snippets.

@doitian
Created June 4, 2009 08:08
Show Gist options
  • Save doitian/123505 to your computer and use it in GitHub Desktop.
Save doitian/123505 to your computer and use it in GitHub Desktop.
rm -rf /tmp/git_exp
cd /tmp
# create a repository
mkdir -p git_exp/one
cd git_exp/one
git init
touch a
git add a
git commit -m '1st commit in master'
# create a branch
git branch br1
git checkout br1
touch b
git add b
git commit -m '2st commit in branch br1'
git checkout master
# now clone it
cd /tmp/git_exp
git clone one/.git two
cd two
git pull origin br1:br1
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline master
# 163e0567f9e3b2632633127e69de3c6ada41edbf 2st commit in branch br1
# is merged to branch master
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline br1
# 163e0567f9e3b2632633127e69de3c6ada41edbf 2st commit in branch br1
# br1 is synced with remote br1
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline origin/master
# cce53db07b11572f819f171416a84de74ddcf8af 1st commit in master
# tracked origin master is synced with remote master, updated in clone, not pull!!!
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline origin/br1
# 163e0567f9e3b2632633127e69de3c6ada41edbf 2st commit in branch br1
# tracked origin master is synced with remote br1, updated in clone, not pull!!!
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline remotes/origin/master
# cce53db07b11572f819f171416a84de74ddcf8af 1st commit in master
# origin matster is feteched into remotes/origin/master
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline remotes/origin/br1
# 163e0567f9e3b2632633127e69de3c6ada41edbf 2st commit in branch br1
# origin br1 is feteched into remotes/origin/br1 in clone!!! but not pull
# make another commit in origin
cd /tmp/git_exp/one
git checkout br1
touch c
git add c
git commit -m '3rd commit in branch br1'
# Go back and pull
cd /tmp/git_exp/two
git pull origin br1:br1
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline master
# 1b03f6e5d20408d90616a82b5e315edb6047014d 3rd commit in branch br1
# Still merged
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline br1
# 1b03f6e5d20408d90616a82b5e315edb6047014d 3rd commit in branch br1
# remote is fetched into here
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline origin/master
# cce53db07b11572f819f171416a84de74ddcf8af 1st commit in master
# tracked origin master is synced with remote master, updated in clone, not pull!!!
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline origin/br1
# 163e0567f9e3b2632633127e69de3c6ada41edbf 2st commit in branch br1
# tracked origin master is synced with remote br1, updated in clone, not pull!!!
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline remotes/origin/master
# cce53db07b11572f819f171416a84de74ddcf8af 1st commit in master
#
# ian@ian-desktop:/tmp/git_exp/two$ git show --pretty=oneline remotes/origin/br1
# 163e0567f9e3b2632633127e69de3c6ada41edbf 2st commit in branch br1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment