From: Junio C Hamano Date: Fri, 13 Jan 2006 19:37:29 GMT Subject: Re: My first git success Message-ID: <7vmzhz7wcm.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <86y81kvtvj.fsf@blue.stonehenge.com> merlyn@stonehenge.com (Randal L. Schwartz) writes: > However, before I bug-fix, I have to "snapshot" any working changes in the > ajax branch or I would lose them on "git-checkout master", which gives me > commits that look like "snapshot". Am I doing that wrong? Is there a better > way to do parallel development of a "live vs upgrade" branch, and make commits > only when I make progress? Although I am sure others would suggest to use more than one working tree, here are what I generally do, which does not require more than one. -- >8 -- Interrupted workflow -------------------- When you are in the middle of a large change, you can get interrupted. The files in your working tree is not in any shape to be committed, but you need to get to the other branch for a quick fix. ------------ : on ajax; work work work : on ajax; git commit -a -m 'snapshot WIP' <1> : on ajax; git checkout master : on master; fix fix fix : on master; git commit ;# commit with real log : on master; git checkout ajax : on ajax; git reset --soft HEAD^ ;# go back to WIP state <2> <1> This commit will get blown away so short log message is just fine. <2> This removes the 'WIP' commit from the commit history, and makes your working tree in the state just before you made that snapshot. ------------ The only difference between the state immediately before <1> and immediately after <2> is that files you committed in <1> are still registered in index at state <2>, so your "git diff" would not give you what you were in the middle of doing at point <2> and you need to say "git diff HEAD" instead. You could do a ------------ : on ajax; git read-tree -m HEAD ------------ immediately after the soft reset, which sets your index file to the last commit you were basing your ajax work on.