git 如何在没有历史记录的系统上从分支 A 挑选到分支 B?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29393875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to cherry pick from branch A to branch B on a system without history?
提问by Farrukh Chishti
Suppose I have a new system with no git history and I take a fresh checkout of branch A. Branch A already has a commit C1 which I did yesterday from some other system. Now I want to cherry-pick this commit C1 in branch B. Issue:
假设我有一个没有 git 历史记录的新系统,并且我对分支 A 进行了新的结帐。分支 A 已经有一个我昨天从其他系统所做的提交 C1。现在我想在分支 B 中挑选这个提交 C1。问题:
- If I take checkout of branch A and go to commit C1 (in history in Git view) and click 'cherry pick', it says do you want to cherry pick in branch A? So, there is no discussion of branch B here.
- If I take checkout of branch B it will not show commit C1 at all.
- 如果我结帐分支 A 并转到提交 C1(在 Git 视图中的历史记录中)并单击“樱桃选择”,它会说您要在分支 A 中选择樱桃吗?所以,这里不讨论分支B。
- 如果我检出分支 B,它根本不会显示提交 C1。
Now, how do I cherry pick commit C1 of branch A into branch B? I am using Gerrit, GitBlit and EGit in eclipse.
现在,我如何将分支 A 的提交 C1 挑选到分支 B 中?我在 Eclipse 中使用 Gerrit、GitBlit 和 EGit。
采纳答案by Ben Siver
I'm not familiar with the GUI you are using in particular, but the concept you are describing is perfectly acceptable in git.
我不熟悉您正在使用的 GUI,但您所描述的概念在 git 中是完全可以接受的。
To cherry-pick a commit from branch A to branch B, use the following command line commands:
要挑选从分支 A 到分支 B 的提交,请使用以下命令行命令:
git checkout branchB
git cherry-pick hashOfC1
There should be a sort of 'view all branches' mode in the GUI you are using so that you can see commit C1 while having branch B checked out, but if not, the above commands are simple enough to execute.
在您使用的 GUI 中应该有一种“查看所有分支”模式,这样您就可以在检出分支 B 的同时看到提交 C1,但如果没有,上述命令很容易执行。
回答by Daniel Sokolowski
回答by Faisal Ahmed Siddiqui
goto "Team Synchronizing", right click on project to display the menu. select show In -> History. This will display History tab with changesets.
转到“团队同步”,右键单击项目以显示菜单。选择显示在 -> 历史记录。这将显示带有变更集的历史选项卡。
when you click on icon with 2 arrows downwards then you will see all the changes even those not from your branch. Right click on changeset that you want to cherry pick and then select Cherry Pick.. option as shown in the picture
当您单击带有 2 个向下箭头的图标时,您将看到所有更改,即使不是来自您的分支的更改。右键单击要挑选的变更集,然后选择 Cherry Pick.. 选项,如图所示