hint: after resolving the conflicts, mark the corrected paths

58.1k views Asked by At

git sometimes gives me this message on a conflict (during a revert or cherry pick)

hint: after resolving the conflicts, mark the corrected paths

What does this mean?

3

There are 3 answers

8
Nick Volynkin On BEST ANSWER

This means that you need to explicitly tell Git that you've resolved a conflict at each file or folder (that is path).

1. Look at the list of files with yet unresolved conflicts

git status

2. Mark each file as resolved

Once you have resolved conflicts in a file, add it to mark that conflicts are resolved:

git add file-which-had-conflicts

If you would like to remove the file instead of resolving conflicts, do it with git rm. However, it's a rare case.

git rm file-which-had-conflicts

3. Proceed with rebase/merge/whatever

git rebase --continue
git merge --continue
git cherry-pick --continue
0
xirong On

because some files are in conflict ,you can type git status to find out what is the file with conflict, and after the conflict was sovled ,just git commit -m sth log ,at last git cherry-pick your-commmit-id . see details http://wiki.koha-community.org/wiki/Using_Git_Cherry_Pick#Resolve_conflicts

0
VonC On

This... can be confusing, and with Git 2.34 (Q4 2021), the advice message that "git cherry-pick"(man) gives is clearer:

When it demands conflicted replay of a commit to be resolved by the end user, it now (Git 2.34, Q4 2021) says:

  • for git cherry-pick:
After resolving the conflicts, mark them with
`git add`/`rm <pathspec>`, then run
`git cherry-pick --continue`

You can instead skip this commit with `git cherry-pick --skip`.

To abort and get back to the state before `git cherry-pick`
run `git cherry-pick --abort`.
  • for git revert:
After resolving the conflicts, mark them with
`git add`/`rm <pathspec>`, then run
`git revert --continue`

You can instead skip this commit with `git revert --skip`.

To abort and get back to the state before `git revert`
run `git revert --abort`.

See commit f172556 (22 Aug 2021) by ZheNing Hu (adlternative).
(Merged by Junio C Hamano -- gitster -- in commit 173368d, 10 Sep 2021)

cherry-pick: use better advice message

Mentored-by: Christian Couder
Mentored-by: Hariom Verma
Helped-by: Phillip Wood
Helped-by: Junio C Hamano
Signed-off-by: ZheNing Hu

"git cherry-pick"(man), upon seeing a conflict, says:

hint: after resolving the conflicts, mark the corrected paths 
hint: with `git add <paths>` or `git rm <paths>` 
hint: and commit the result with `git commit`.

As if running "git commit" to conclude the resolution of this single step were the end of the story.

This stems from the fact that the command originally was to pick a single commit and not a range of commits, and the message was written back then and has not been adjusted.

When picking a range of commits, and the command stops with a conflict in the middle of the range, however, after resolving the conflict and (optionally) recording the result with "git commit", the user has to run "git cherry-pick --continue" to have the rest of the range dealt with, "--skip" to drop the current commit, or "--abort" to discard the series.

Suggest use of "git cherry-pick --continue/--skip/--abort so that the message also covers the case where a range of commits are being picked.

Similarly, this optimization can be applied to git revert(man), suggest use of "git revert --continue/--skip/--abort so that the message also covers the case where a range of commits are being reverted.

It is worth mentioning that now we use advice() to print the content of GIT_CHERRY_PICK_HELP in print_advice(), each line of output will start with "hint: ".


"git cherry-pick"(man) invoked during git rebase -i(man) session lost the authorship information, which has been corrected with Git 2.44 (Q1 2024), before 2.44 final.

See commit e4301f7 (02 Feb 2024) by Vegard Nossum (vegard).
(Merged by Junio C Hamano -- gitster -- in commit c036a14, 14 Feb 2024)

sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands

Helped-by: Phillip Wood
Signed-off-by: Vegard Nossum

Running "git cherry-pick"(man) as an x-command in the rebase plan loses the original authorship information.

To fix this, unset GIT_CHERRY_PICK_HELP for 'exec' commands.


With Git 2.45 (Q2 2024), batch 9, CHERRY_PICK_HEAD is no longer used.

See commit 72a8d3f (27 Feb 2024) by Phillip Wood (phillipwood).
(Merged by Junio C Hamano -- gitster -- in commit 184969c, 18 Mar 2024)

rebase -i: stop setting GIT_CHERRY_PICK_HELP

Signed-off-by: Phillip Wood

Setting this environment variable causes the sequencer to display a custom message when it stops for the user to resolve conflicts and remove CHERRY_PICK_HEAD.
Setting it in "git rebase"(man) is a vestige of the scripted implementation, now that it is a builtin command we do not need to communicate with the sequencer machinery via environment variables.

Move the conflicts advice to use when rebasing into sequencer.c so we do not need to pass it via the environment.

Note that we retain the changes in e4301f7 ("sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands", 2024-02-02, Git v2.44.0-rc2 -- merge) just in case GIT_CHERRY_PICK_HELP is set in the environment when "git rebase" is run.