I cherry picked a commit, from two years ago and fixed the conflicts (as well as committing the change), but when I try and cherry pick a commit from five months ago:
$: git cherry-pick 9f73972f3f619f1357269493e01f07c500d61ed9
On branch get_ndt_up_to_staging_branch
You are currently cherry-picking commit 9f73972.
nothing to commit, working tree clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
git commit --allow-empty
Otherwise, please use 'git reset'
How is that true? When I look on github, the commit in question has changes to various files.
Am I doing something wrong?
When I fixed all conflicts I committed them and attempted to do cherry-pick --continue and it gave me the same error. Did I do cherry pick wrong?
Typically you get this error if the changes in the commit are already in the current version of the code. In that case, git decides that the cherry-pick would result in a commit that makes no changes, so it asks whether you want to allow an empty commit with --allow-empty
.
If you fixed conflicts and the result of the resolution again matches with the current state of the working tree and current HEAD, then you will get the same error.
I'd recommend taking a close look with git show 9f73972
and compare with the current state of your working tree and repository.
It sounds like the result of fixing the conflicts is that there is no need to take the commit.
Consider, for instance, a commit that consists of a one-word spelling fix:
--- a/text.txt
+++ b/text.txt
@@ -nn,1 +nn,1 @@
some context
is here
-and there was a tyop
+and there was a typo
in one of the
lines
Suppose you decide to cherry-pick this commit. In your current ( HEAD
) commit, this same file has:
some context
is here
but there are no typos
in one of the
lines
The cherry-pick operation will tell you that there is a conflict between the change you are cherry-picking (which tries to change "tyop" to "typo" in that line) with the version that you are actually using (which does not have that line at all).
When you look at the file and think about it, you will probably choose to use the latest line, which has no typo to fix. The effect of applying the typo fix, then, is to make no changes to the source .
When you run git cherry-pick --continue
, Git will tell you that you made no changes. You must now decide:
git commit --allow-empty
. git cherry-pick --abort
(to end the operation entirely). This is also spelled git reset
(I prefer the git cherry-pick --abort
spelling).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.