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

Re: how to automatically open conflicted files when "git rebase" encounter conflict

From
EEErik Cervin Edin <erik@cervined.in>
Date
Mar 18, 2022, 16:00 UTC
Message-ID
<CA+JQ7M8_QiidajaWJpz3gFeUXiLMLiDA38W1mnWyxnMLJN3fpQ@mail.gmail.com>
In-Reply-To
<bc7b04de-17be-df86-1c93-792903eeec9b@mails.ucas.ac.cn>
On Fri, Mar 18, 2022 at 8:02 AM wuzhouhui <wuzhouhui14@mails.ucas.ac.cn> wrote:
Show 9 quoted lines
>
> Hi
>
> When "git rebase" stopped due to conflict, I have to manually open
> conflicted
> file one by one and resolve conflict, and the typing file path is too
> boring.
> So, how to automatically open (e.g. use Vim) conflicted files?
>
Hi!
I rebase quite a lot and my strategy is as follows
  git diff
allows me to quickly overview the conflicted files and conflicts.
Usually, I want to either take all *ours* (the stuff I've rebased
onto) or *theirs* (the incoming rebased commit).
To do this quickly I've developed a script (basically glue-code of git => sed)
https://github.com/CervEdin/gut/blob/main/git-resolve.sh
which can be invoked
  git resolve -o/t/b (--ours/theirs/both) 'pathspec'
More information on the underlying implementation can be found in this
stackoverflow answer
https://stackoverflow.com/a/68498101/
The script is something I've developed for my own use and very much
not bug free.
Nevertheless, I personally find it efficiently covers the case of
basic conflicts I encounter.
In the situations of more complicated conflicts (as well as the
functionality you request) can be invoked using
  git mergetool
  git mergetool -- 'pathspec'
  git mergetool --tool=vimdiff -- 'pathspec'
That is unless you want to solely use vim without vimdiff.
The main downside is that invoking mergetool is a bit slow :/
Previous: wuzhouhuiNext: Junio C Hamano
Message 5 of 8 in “how to automatically open conflicted files when "git rebase" encounter conflict”
  1. wuzhouhuiMar 18, 2022
  2. Junio C HamanoMar 18, 2022
  3. Erik Cervin EdinMar 18, 2022
  4. wuzhouhuiMar 19, 2022
  5. Erik Cervin EdinMar 18, 2022
  6. Junio C HamanoMar 18, 2022
  7. brian m. carlsonMar 18, 2022
  8. Junio C HamanoMar 18, 2022

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.