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

Re: git merge --abort

From
BDBryan Donlan <bdonlan@gmail.com>
Date
Feb 21, 2009, 07:28 UTC
Message-ID
<3e8340490902202328r7caca98q973c17dc163e2028@mail.gmail.com>
In-Reply-To
<7v7i3lk7dp.fsf@gitster.siamese.dyndns.org>
On Fri, Feb 20, 2009 at 12:24 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> John Tapsell <johnflux@gmail.com> writes:
>
>> 2009/2/19 Jay Soffian <jaysoffian@gmail.com>:
>>> On Thu, Feb 19, 2009 at 8:34 AM, John Tapsell <johnflux@gmail.com> wrote:
>>>> There's no reliable way of getting back to the state before the merge?
>>>
>>> Sure there is. Commit or stash before you merge, so that your index
>>> and working copy are clean.
>>
>> Could a stash be done automatically by the merge command, for just a case?
>
> It cuts both ways.  For people who work on a well organized project
> (i.e. highly modularized) and tend to keep local changes in the work tree
> while doing a lot of merges, running "stash" every time would (1) remove
> the local change from the work tree, which he has to remember to manually
> unstash after resolving conflicts in the merge (which would not have
> conflicted with the local change anyway), which is an additional work for
> no real gain, and (2) clutter his stash.  My gut feeling is that it is a
> change that affects the way the end user has to work that is sufficiently
> different and disruptive for no real gain.

Perhaps a better approach would be to stash the pre-merge state in the reflog, then? That is, manufacture a pre-merge commit containing all files changed in the working copy, and add it to the reflog prior to performing a merge. git merge --abort can then simply check whether the top reflog entry is a pre-merge state, and if so, reset --hard to it, then reset the index to the parent of our pre-merge commit.

This would also nicely handle the case where the user tries some random things before deciding to abort the merge.

Previous: John TapsellNext: Jakub Narebski
Message 10 of 18 in “git merge --abort”
  1. John TapsellFeb 19, 2009
  2. Junio C HamanoFeb 19, 2009
  3. John TapsellFeb 19, 2009
  4. Jay SoffianFeb 19, 2009
  5. John TapsellFeb 20, 2009
  6. Junio C HamanoFeb 20, 2009
  7. John TapsellFeb 20, 2009
  8. Junio C HamanoFeb 20, 2009
  9. John TapsellFeb 20, 2009
  10. Bryan DonlanFeb 21, 2009
  11. Jakub NarebskiFeb 21, 2009
  12. Junio C HamanoFeb 21, 2009
  13. Jakub NarebskiFeb 21, 2009
  14. John TapsellFeb 23, 2009
  15. Junio C HamanoFeb 24, 2009
  16. Jakub NarebskiFeb 24, 2009
  17. Junio C HamanoFeb 24, 2009
  18. Jakub NarebskiFeb 24, 2009

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.