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

Re: Better cooperation between checkouts and stashing

From
MEMarkus Elfring <markus.elfring@web.de>
Date
Feb 28, 2010, 13:55 UTC
Message-ID
<4B8A75D9.2090702@web.de>
In-Reply-To
<7vr5o6s5xf.fsf@alter.siamese.dyndns.org>
> It is important to understand that a local change does not belong to your
> current branch (it does not belong to _any_ branch).  It belongs to you,
> and you can take it around while switching between branches.  And that is
> a big time-saving feature.

It seems that we have got different expectations on the editing work flow when we discuss the following situation.

elfring@Sonne:~/Projekte> git --version && mkdir try && cd try && git init --quiet \
> && echo one > XYZ.h && git add . && git commit --message=check-in --quiet \
> && git checkout --quiet -b feature1 && echo two > XYZ.h \
> && git checkout --quiet master && git status

git version 1.7.0 # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: XYZ.h # no changes added to commit (use "git add" and/or "git commit -a")

I would prefer to return to the unchanged work tree because I made an adjustment for a source file with the intention that this update should only belong to the new topic branch. The switch did not provide a clean state from my view.

>  - You are reading a mailing list message that asks for help, and you know
>    the solution---you can give the help real quick.
> 
>  - You hack in whatever branch that happen to be checked out.
I would create another topic branch before.
Show 7 quoted lines
>  - The branch you happen to have checked out was 'next', but the solution
>    is a bugfix, and should go to 'maint'.
> 
> Now, at this point, you want to checkout 'maint' without losing your local
> change.  The paths you touched with your quick fix are often not different
> between the two branches, and "checkout maint" will checkout the branch
> while keeping your local changes intact.

I can follow your view on convenience if the desired software maintenance is so easy as in this example. I guess that it matters if only a simple branch switch is needed or a corresponding content restore will also be required.

Show 5 quoted lines
> In a case where "checkout -m" would result in a conflict too big to
> resolve, the original fix you made would not be applicable to 'maint'
> (iow, you should have solved it differently starting from 'maint'), and
> you may end up doing "reset --hard" and start from scratch, but that is a
> rare worst case.
I would like to be more careful so that I do not want to mix changes by accident.
Show 5 quoted lines
> I said it is rare, because you would notice, while doing the "quick fix"
> based on 'next' codebase, that the code you are touching have changed
> since 'maint' and won't be applicable to its final destination (by that
> time you know you are "fixing"), and you won't waste too much time
> continuing to work in a checkout of 'next'.

I imagine that stashing will help to split the collected changes for different branch targets.

Regards, Markus

Previous: Junio C HamanoNext: Michael Witten
Message 15 of 56 in “Better cooperation between checkouts and stashing”
  1. Markus ElfringFeb 1, 2010
  2. Junio C HamanoFeb 1, 2010
  3. Markus ElfringFeb 1, 2010
  4. Eugene SajineFeb 1, 2010
  5. Petr BaudisFeb 2, 2010
  6. Markus ElfringFeb 2, 2010
  7. Petr BaudisFeb 2, 2010
  8. Markus ElfringFeb 9, 2010
  9. Junio C HamanoFeb 9, 2010
  10. Markus ElfringFeb 9, 2010
  11. Markus ElfringFeb 18, 2010
  12. Junio C HamanoFeb 18, 2010
  13. Markus ElfringFeb 27, 2010
  14. Junio C HamanoFeb 27, 2010
  15. Markus ElfringFeb 28, 2010
  16. Michael WittenFeb 28, 2010
  17. Markus ElfringMar 1, 2010
  18. Michael WittenMar 1, 2010
  19. Junio C HamanoMar 1, 2010
  20. Michael WittenMar 1, 2010
  21. Markus ElfringMar 1, 2010
  22. Junio C HamanoMar 1, 2010
  23. Markus ElfringMar 1, 2010
  24. Michael WittenMar 2, 2010
  25. Markus ElfringMar 2, 2010
  26. Junio C HamanoMar 2, 2010
  27. Markus ElfringMar 3, 2010
  28. Michael WittenMar 4, 2010
  29. Markus ElfringMar 4, 2010
  30. Markus ElfringMar 2, 2010
  31. Junio C HamanoMar 2, 2010
  32. Markus ElfringMar 3, 2010
  33. Markus ElfringMar 17, 2010
  34. Avery PennarunMar 17, 2010
  35. Markus ElfringMar 17, 2010
  36. Junio C HamanoMar 17, 2010
  37. Markus ElfringMar 17, 2010
  38. Junio C HamanoMar 17, 2010
  39. Michael WittenMar 17, 2010
  40. Junio C HamanoMar 17, 2010
  41. Markus ElfringMar 18, 2010
  42. Avery PennarunMar 18, 2010
  43. Michael WittenMar 18, 2010
  44. Avery PennarunMar 18, 2010
  45. Markus ElfringMar 19, 2010
  46. Avery PennarunMar 19, 2010
  47. Markus ElfringMar 20, 2010
  48. Markus ElfringMar 19, 2010
  49. Markus ElfringMar 30, 2010
  50. Junio C HamanoMar 30, 2010
  51. Ramkumar RamachandraMar 31, 2010
  52. Junio C HamanoApr 1, 2010
  53. Ramkumar RamachandraApr 1, 2010
  54. Markus ElfringApr 1, 2010
  55. Markus ElfringApr 10, 2010
  56. Junio C HamanoApr 10, 2010

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.