tags:

views:

27

answers:

2

Using cvs, git or another technique (file system level?), I would like to:

  1. Make modifications on branch A

  2. Checkout branch B: Changes to branch A are "stowed away" (by name would be nice), branch B is checked out such that my branch A changes are gone

  3. Make modifications on branch B

  4. Checkout branch A: Changes to branch B are "stowed away" (by name would be nice), branch A is checked out such that my branch B changes are gone but now my "saved" branch A changes from Step #2 are back

Git-stash does not appear to fit the flow I'm describing although my impression could be wrong.

Techniques involving RCS's or file system or command-line tools or otherwise are welcome.

A: 

git stash is the tool you are looking for

# hack on A
git stash

git checkout B
# hack on B
git stash

git checkout A
git stash list # this is only to check which stash you want to pop
git stash pop stash@{1}

this should work

knittl
Ah, my impression definitely was wrong! Thank you for the very helpful little tutorial.
Darvan Shovas
You can also stash a name/message with your content using `git stash save 'Changes made before switching branches or whatever'`. I find that helpful most of the time.
Rob Wilkerson
@rob beautiful, thanks
Darvan Shovas
A: 

How does git-stash not fit your workflow, beyond not happening automatically? This sounds like exactly what git-stash is for.

http://book.git-scm.com/4_stashing.html

rayners
I guess I was wrong git-stash definitely does seem to be what I want. A little too manual but perhaps I could script something around it.
Darvan Shovas
I would be completely lost without git-stash, I think.
rayners