gitcherry-pick 没有说要提交什么
(注意:这不是重复的问题,请参阅下面的解释)
我首先将 master 作为一个独立的分支签出:
% 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'.
然后我尝试挑选我的分支:
% 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'
根据 这篇之前的 StackOverflow 帖子,这表明我正在挑选的提交不包含任何新更改。但是 git diff 说它确实如此:
% 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
(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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
git diff 65b12d9d32
将提交 65b12d9d32 的树与当前工作副本进行比较。由于您的工作副本是干净的,因此它相当于git diff HEAD 65b12d9d32
另一方面,
gitcherry-pick 65b12d9d32
计算提交 65b12d9d32 与其父级之间的差异 - 更改“由”提交 65b12d9d32 引入。您可以使用 git show 65b12d9d32 或 git diff 65b12d9d32^ 65b12d9d32 来查看(
^
意思是“第一个父级”)。从那里开始,它可能与您链接的问题相同:为什么git-cherrypick 没有说要提交什么吗?
git diff 65b12d9d32
compares the tree as of commit 65b12d9d32 to your current working copy. Since your working copy is clean, it's equivalent togit 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
, orgit 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?
使用 git stash 存储当前的所有更改。
然后运行 gitcherry-pick -n {comitId}。如果您的分支和 {commitId} 之间存在任何差异,那么它将被暂存到您当前的分支。
将
-n
与cherry-pick 一起使用不会对您的分支进行提交。它仅暂存更改(如果有)。您现在可以使用 git diff 检查这些差异。
如果它显示没有任何更改,则意味着来自 {commitId} 的代码已经在您当前的分支中。
如果它显示任何更改,那么您可以使用 git commit -m {message} 提交它们
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}