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

Re: Teach git-gui about merging around modified files?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 29, 2007, 09:04 UTC
Message-ID
<20070729090431.GO20052@spearce.org>
In-Reply-To
<20070729073652.GN20052@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
Show 12 quoted lines
> Brian Downing <bdowning@lavos.net> wrote:
> > "git merge" will happily merge a change with modified files in the tree
> > as long as the merge doesn't touch any of them.  However, it appears
> > "git gui" won't even try if there are modified files at all.
> 
> Yes.  That is actually intentional...
> 
> If you merge and get conflicts you cannot abort to your pre-merge
> state safely by just doing a `git reset --hard` (or git-gui's own
> builtin action that does the same) as you will toss your own not
> yet committed changes too.  You really need to save those changes
> off first.

I felt bad about my original response to this thread. Telling a user that their workflow is broken and should be changed is not very nice, and not user friendly.

So I just spent a couple of hours trying to teach git-gui to first save off your index and working directory, then run the merge, and during abort let you restore things even if they weren't committed.

During testing I learned that you can't merge if you have any staged but uncommitted changes. If you try git-merge-recursive just aborts and refuses to execute the merge, even if the file paths aren't in conflict and won't require a file level merge. The issue is the files are staged in the index and would commit as part of the merge commit, rather than staying out until after, so the merge driver is really doing the right thing here.

I'm still convinced that merging while you have uncommitted changes in the working directory is really bad. Its nearly impossible to recover from a conflict and get back to pre-merge state, and its also confusing to resolve conflicts because your unstaged but modified files are still showing in the status.

I'm going to shelve this work until post 0.8.0 and try to rework it using git-stash as part of git-gui 0.9.0. Ideally you should be able to stash your work before merging, and unstash after the merge is complete.

-- 
Shawn.
Previous: Shawn O. Pearce
Message 3 of 3 in “Teach git-gui about merging around modified files?”
  1. Brian DowningJul 27, 2007
  2. Shawn O. PearceJul 29, 2007
  3. Shawn O. PearceJul 29, 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.