February 24, 2010

Git Stash

Boss says to both Person 1 & Person 2: make me an app that displays every single number in pi.

  • you make a new file: touch pi.rb
  • type puts '3.141'

    Boss says: wait, wait…first make me an app that counts to 10

  • you sigh
  • you type into the command line git stash save
  • you make a new file touch count.rb
  • type into the new file puts '1,2,3,444,5,6,7,8,9,10' (yes, 444)
  • git commit -am "count to ten finished"
  • git stash apply

Use git stash if want to switch out your working set to another branch, work on something else, then switch back to your original work. A second possible git stash scenario is if you aren’t ready to commit but you need to pull (something that you and someone else are both modifying)