git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Cervin Edin <erik@cervined.in>
To: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
Cc: git@vger.kernel.org
Subject: Re: how to automatically open conflicted files when "git rebase" encounter conflict
Date: Fri, 18 Mar 2022 17:00:37 +0100	[thread overview]
Message-ID: <CA+JQ7M8_QiidajaWJpz3gFeUXiLMLiDA38W1mnWyxnMLJN3fpQ@mail.gmail.com> (raw)
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:
>
> 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 :/

  parent reply	other threads:[~2022-03-18 16:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18  2:00 how to automatically open conflicted files when "git rebase" encounter conflict wuzhouhui
2022-03-18  4:11 ` Junio C Hamano
2022-03-18 16:01   ` Erik Cervin Edin
2022-03-19  2:01   ` wuzhouhui
2022-03-18 16:00 ` Erik Cervin Edin [this message]
2022-03-18 18:24   ` Junio C Hamano
2022-03-18 20:14 ` brian m. carlson
2022-03-18 21:25   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+JQ7M8_QiidajaWJpz3gFeUXiLMLiDA38W1mnWyxnMLJN3fpQ@mail.gmail.com \
    --to=erik@cervined.in \
    --cc=git@vger.kernel.org \
    --cc=wuzhouhui14@mails.ucas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).