February 24, 2010

Git Branch

Boss says: One person in each pair should clone the other person’s git repo from github so that you are both working on the same repo.

  • git clone git@github.com:<user name>/git_demo.git git_demo_clone

Boss says: I want one person in the pair to make the app say “My boss is the best boss ever!” The other should make it say “Welcome to the best Ruby app ever written!”

Person 1:
  • git branch (shows you master branch, a branch that was auto-created by git for you)
  • git branch best_boss (creates a new branch called best_boss)
  • git branch (you can see the two branches you have. The ‘*’ indicates which branch you are currently on)
  • git checkout best_boss (moves you to the new best_boss branch you created)
  • git branch (now the ‘*’ is next to best_boss)
  • type puts "My boss is the best boss ever!" into hello.rb
  • git commit -am "updated hello.rb with best boss text"
  • git push origin best_boss
Person 2:
  • git branch (shows you master branch, a branch that was auto-created by git for you)
  • git branch best_app (creates a new branch called best_app)
  • git branch (you can see the two branches you have. The ‘*’ indicates which branch you are currently on)
  • git checkout best_app (moves you to the new best_app branch you created)
  • git branch (now the ‘*’ is next to best_app)
  • type puts "Welcome to the best Ruby app ever written!" into hello.rb
  • git commit -am "updated hello.rb with best app text"
  • git push origin best_app

show your branches to your the boss.