合并 Git 分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5671967/
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
Merging Git Branches
提问by Serodis
I have two branches, one is the master, one is 'test.' This name was dual-purpose, I was not only testing the branches, but testing out some changes as well. Now, I have the test branch working great. However, I am not working alone. The master branch is being worked on too. Now, I would love to copy my test branch over to the main. Then, I would love to do a pull and see what changes have been made so I can push the changes.
我有两个分支,一个是master,一个是'test'。这个名字是双重用途的,我不仅是在测试分支,还测试了一些变化。现在,我的测试分支运行良好。然而,我并不是一个人工作。master 分支也正在开发中。现在,我很想将我的测试分支复制到主分支。然后,我很想拉一下,看看做了哪些更改,以便我可以推动更改。
First, I am using Aptana. I tried the drop-down settings button. I clicked and attempted to merge while on the Master branch with the 'test' branch. This did something, not really sure what. It then said I had a problem. So, now, I ran git mergetool, and again, this did something. It said everything was good.Now, the two branches are both working as they should, however, they are not identical. In fact, they are both exactly what they were before any merge took place.
首先,我正在使用 Aptana。我尝试了下拉设置按钮。我在主分支上单击并尝试与“测试”分支合并。这做了一些事情,不太确定是什么。然后说我有问题。所以,现在,我运行了 git mergetool,再次,这做了一些事情。它说一切都很好。现在,这两个分支都在正常工作,但是,它们并不相同。事实上,它们都与发生任何合并之前完全一样。
What can I do to fix this? 'test' is the important branch right now, it has all my work. Master has some important stuff, but not locally. Any suggestions would be great.
我能做些什么来解决这个问题?'test' 现在是重要的分支,它包含我所有的工作。Master有一些重要的东西,但不是本地的。任何建议都会很棒。
回答by fedeisas
First of all, commit and push every change in both branches.
首先,提交并推送两个分支中的每个更改。
Then, checkout to master, and merge test:
然后,结帐到掌握,并合并测试:
$git checkout master
$git merge test
It should display warning on every file that has a problem with merging. Sometimes Git can't figure out the "right" merge and you have to manually fix it. Go to those files, check for merge problems (they're easy to guess, Git wraps problems in <<<< ==== >>>>) And that's it! You have successfully merged test on master. Hope it helps!
它应该在每个有合并问题的文件上显示警告。有时 Git 无法找出“正确”的合并,您必须手动修复它。转到这些文件,检查合并问题(它们很容易猜到,Git 将问题包装在 <<<< ==== >>>> 中)就是这样!您已成功在 master 上合并测试。希望能帮助到你!
回答by VonC
The Aptana Git integration isn't as mature or advanced as the EGit one(see Aptana ticket 1372). And it involves having Git installed and correctly setup first.
Aptana Git 集成不像EGit那样成熟或先进(请参阅Aptana 票证 1372)。它涉及首先安装并正确设置 Git。
Christopher Williamsis working hard on improving the Aptana Git plugin, but in case of problem, going back to a shell session, like fedeisas's answerillustrates, is the best option.
Christopher Williams正在努力改进 Aptana Git 插件,但如果出现问题,返回到 shell 会话(如fedeisas的回答所示)是最佳选择。