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

Re: Data Integrity & un-Commited Branches

From
JHJan Hudec <bulb@ucw.cz>
Date
Sep 15, 2007, 07:38 UTC
Message-ID
<20070915073845.GB3782@efreet.light.src>
In-Reply-To
<20070915025129.GY3099@spearce.org>
On Fri, Sep 14, 2007 at 22:51:29 -0400, Shawn O. Pearce wrote:
Show 5 quoted lines
> It isn't unreasonable to want Git to save uncommitted work for the
> current branch and then you switch to another, ending up with a
> clean working directory when you finally get there.  Today we have
> git-stash to help you with this, but I'm thinking maybe we want to
> connect git-checkout with it?

I think it would be reasonable if it just forced you to decide about it. That is reading the documentation, checkout only switches branches if the merge of each modified file is trivial and only does 3-way merge if it got -m option.

It might be reasonable to requre that option for all cases, where there are local changes and the branches don't point to the same commit and without it, checkout should say something like:

  Cannot switch branches, because the tree is modified. You can apply the
  modifications to the target branch by using -m option, or commit them
  before switching branches (you can undo or amend that commit later if it's
  not finished yet).

The case with branches pointing to the same commit is for checkout -b, reverting that command if you do it too early/by mistake/wanted branch instead and for doing it with branch + checkout.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Brian Scott DobrovodskyNext: Shawn O. Pearce
Message 7 of 12 in “Re: Data Integrity & un-Commited Branches”
  1. Brian Scott DobrovodskySep 15, 2007
  2. Shawn O. PearceSep 15, 2007
  3. Brian Scott DobrovodskySep 15, 2007
  4. Shawn O. PearceSep 15, 2007
  5. Junio C HamanoSep 15, 2007
  6. Brian Scott DobrovodskySep 15, 2007
  7. Jan HudecSep 15, 2007
  8. Shawn O. PearceSep 15, 2007
  9. Nikodemus SiivolaSep 15, 2007
  10. David KastrupSep 15, 2007
  11. Nikodemus SiivolaSep 15, 2007
  12. David KastrupSep 15, 2007

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.