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

Re: [BUG] git checkout <branch> allowed with uncommitted changes

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 13, 2011, 18:28 UTC
Message-ID
<7vzkh44ug1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<loom.20111013T193054-868@post.gmane.org>
arQon <arqon@gmx.com> writes:
> ..., in the absence of either of those flags, git
> WILL preserve the worktree by refusing to switch until that potentially-
> harmful situation is resolved by the user.

Perhaps you can prepare a documentation patch to make it clear that git WILL preserve the LOCAL CHANGES to the working tree?

As it would already be clear to anybody reading this thread so far, local changes made to the working tree do not belong to any particular branch. They are floating on top, and it is up to the user what to do with these floating changes when they conflict with the differences between the branches you are switching across (i.e. you cannot switch so you need to clean up by either committing, stashing, or deciding not to switch and instead complete the work before you switch), and when they do not conflict with the differences between the branches you are switching across (i.e. you will carry them to the new working tree. It may be that you made these changes and then realized that they do not belong to the goal the current branch aims to achieve and that is why you decided to switch to another branch, in which case you do not have to do anything special in order to continue to work and complete it to commit to the switched branch. It may be that you made these changes but needed to tend to unrelated business on an unrelated branch and that is why you switched, in which case you would want to clear them away, which is exactly what stash was invented for).

Previous: arQonNext: arQon
Message 19 of 36 in “[BUG] git checkout <branch> allowed with uncommitted changes”
  1. arQonOct 13, 2011
  2. Nguyen Thai Ngoc DuyOct 13, 2011
  3. Alexey ShumkinOct 13, 2011
  4. arQonOct 13, 2011
  5. Andreas EricssonOct 13, 2011
  6. arQonOct 13, 2011
  7. Carlos Martín NietoOct 13, 2011
  8. arQonOct 13, 2011
  9. Alexey ShumkinOct 13, 2011
  10. Jakub NarebskiOct 13, 2011
  11. arQonOct 13, 2011
  12. Carlos Martín NietoOct 13, 2011
  13. arQonOct 13, 2011
  14. Alexey ShumkinOct 13, 2011
  15. Alexey ShumkinOct 14, 2011
  16. Holger HellmuthOct 13, 2011
  17. Carlos Martín NietoOct 13, 2011
  18. arQonOct 13, 2011
  19. Junio C HamanoOct 13, 2011
  20. arQonOct 13, 2011
  21. Jeff KingOct 14, 2011
  22. Holger HellmuthOct 14, 2011
  23. Victor EngmarkOct 14, 2011
  24. arQonOct 16, 2011
  25. Junio C HamanoOct 16, 2011
  26. Holger HellmuthOct 16, 2011
  27. Carlos Martín NietoOct 13, 2011
  28. Sergei OrganovOct 13, 2011
  29. PJ WeisbergOct 13, 2011
  30. Holger HellmuthOct 13, 2011
  31. arQonOct 13, 2011
  32. Holger HellmuthOct 13, 2011
  33. Victor EngmarkOct 13, 2011
  34. arQonOct 13, 2011
  35. Victor EngmarkOct 14, 2011
  36. Michael J GruberOct 13, 2011

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.