git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: My first git success

From
Junio C Hamano <junkio@cox.net>
Date
Jan 13, 2006, 19:37 UTC
Message-ID
<7vmzhz7wcm.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<86y81kvtvj.fsf@blue.stonehenge.com>
merlyn@stonehenge.com (Randal L. Schwartz) writes:
Show 5 quoted lines
> 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.

Previous: Randal L. SchwartzNext: Peter Eriksen
Message 4 of 15 in “My first git success”
  1. waltJan 13, 2006
  2. Linus TorvaldsJan 13, 2006
  3. Randal L. SchwartzJan 13, 2006
  4. Junio C HamanoJan 13, 2006
  5. Peter EriksenJan 13, 2006
  6. waltJan 14, 2006
  7. seanJan 14, 2006
  8. waltJan 14, 2006
  9. Randal L. SchwartzJan 14, 2006
  10. Junio C HamanoJan 14, 2006
  11. Linus TorvaldsJan 14, 2006
  12. waltJan 14, 2006
  13. Junio C HamanoJan 14, 2006
  14. Linus TorvaldsJan 14, 2006
  15. Junio C HamanoJan 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.