(note: this is not a duplicate question, see explanation below)
I first checkout master as a detached branch:
% git checkout --detach master
HEAD is now at fff9e1e687 modserver/go: skip Spotlight automod aspect ratio check for cheerio vids
Your branch is up to date with 'origin/master'.
I then try to cherry pick my branch:
% git cherry-pick my_branch
Already up to date.
HEAD detached at refs/heads/master
You are currently cherry-picking commit 65b12d9d32.
(all conflicts fixed: run "git cherry-pick --continue")
(use "git cherry-pick --skip" to skip this patch)
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
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 cherry-pick --skip'
According to this prior StackOverflow post, this suggests that the commit I'm cherry picking contains no new changes. But git diff
says that it does:
% git diff 65b12d9d32
diff --git a/ranking/acumen/datawizard/BUILD b/ranking/acumen/datawizard/BUILD
deleted file mode 100644
index 1d61abec2f..0000000000
--- a/ranking/acumen/datawizard/BUILD
/dev/null
@@ -1,13 0,0 @@
-load("//tools:go.bzl", "go_library")
-
-go_library(
- name = "go_default_library",
- srcs = [
- "handler.go",
- ],
- visibility = ["//ranking/acumen:__subpackages__"],
- deps = [
- "//ranking/logging/log:go_default_library",
- "@com_github_valyala_fasthttp//:go_default_library",
- ],
-)
diff --git a/ranking/acumen/datawizard/handler.go b/ranking/acumen/datawizard/handler.go
deleted file mode 100644
index 388104cf57..0000000000
--- a/ranking/acumen/datawizard/handler.go
/dev/null
@@ -1,22 0,0 @@
-package datawizard
CodePudding user response:
git diff 65b12d9d32
compares the tree as of commit 65b12d9d32 to your current working copy. Since your working copy is clean, it's equivalent to git diff HEAD 65b12d9d32
On the other hand, git cherry-pick 65b12d9d32
calculates the difference between commit 65b12d9d32 and its parent - the changes "introduced by" commit 65b12d9d32.
You can view that with git show 65b12d9d32
, or git diff 65b12d9d32^ 65b12d9d32
(^
meaning "first parent of").
From there, it is probably the same scenario as the question you linked: Why is git-cherrypick saying nothing to commit?
CodePudding user response:
Stash all your current changes using git stash
.
Then run git cherry-pick -n {comitId}
. If there are any differences between your branch and the {commitId} then it will be staged to your current branch.
Using -n
with cherry-pick does not make a commit to you branch. It only stages the changes, if there are any.
You can check those differences now using git diff
.
If it shows that there are no changes then it means that code from {commitId} is already in your current branch.
If it shows any changes then you can commit them using git commit -m {message}