(git):如何从上游分支带来特定的提交?
我有这个(git repo):
A--B--C--D ->master
\--E ->dev
我只想将提交 D
提交到分支 dev
(D
不依赖于 C
),这样:
A--B--C--D ->master
\--E--D' ->dev
但是 D' 不应该在合并后添加到 master 中:
A--B--C--D--E' ->master
\--E--D'/ ->dev
这是因为我只想带来文件更新,而不必用新文件污染 dev
C
(代表另一个大合并)添加了。
我猜我需要使用 git rebase,但我不知道如何使用。
I have this (git repo):
A--B--C--D ->master
\--E ->dev
And I want to bring only commit D
to branch dev
(D
doesn't depend on C
), so that:
A--B--C--D ->master
\--E--D' ->dev
But D' shouldn't get added to master after a merge:
A--B--C--D--E' ->master
\--E--D'/ ->dev
This is because I want to bring only a file update without having to pollute dev
with new files that C
(which represents another, big merge) adds.
I'm guessing I need to use git rebase
, but I can't guess how.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想使用
gitcherry-pick
。我假设您的遥控器名为“origin”(但将远程存储库的真实名称替换为“origin”)。我假设您有两个本地分支,也分别名为master
和dev
。我假设提交 D 位于origin/dev
上。您可以使用以下命令挑选 D:现在您将仅拥有
dev
中提交 D 的更改。You want to use
git cherry-pick
. I'll assume your remote is named "origin" (but substitute the real name of the remote repo for "origin"). I'll assume you have two local branches also namedmaster
anddev
. I'll assume commit D is onorigin/dev
. You can cherry-pick D with the following:Now you'll only have the changes from commit D in
dev
.使用命令
gitcherry-pick
。Use the command
git cherry-pick
.