如何使用 Git、Eclipse 和 Egit 进行合并
我和许多其他人一样,喜欢 Eclipse 作为我选择的 ide,并且因为我的工作方式(移动,不同的地方,不同的项目)想要使用 Git 进行 CVS。
Eclipse中有一个Git的插件,Egit,它现在是一个官方的Eclipse项目,目前位于版本0.7.1。由于我刚刚开始使用它,我对其他人如何使用它以及他们正在使用的解决方法感兴趣。目前 Egit 不支持合并,因此这些操作必须在 Eclipse 外部完成,然后刷新工作区。
那么,你如何完成这个任务呢? (以及 Egit 目前不执行的任何其他任务)
I, like many others, love Eclipse as my ide of choice, and because of the way I work (moving about, different places, different projects) want to use Git for CVS.
There is a plugin for Git in Eclipse, Egit, which is now an official Eclipse project, and currently at version 0.7.1. As I've just started using it I'm interested in how others are using it, and what work arounds they are using. Currently Egit doesn't have support for merges, so these have to be done outside of Eclipse and then the workspace refreshed.
So, How do you do this task ? (and any other tasks that Egit doesn't do right now)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅供参考,EGIT 现在支持合并并使用 eclipse 中强大的 diff 接口。
获取代码并运行合并后,如果存在任何冲突,它们会在项目资源管理器中以红色 ! 突出显示,然后您可以右键单击它们并转到 Team >合并工具,对于冲突的文件没有重影。
选择要使用的代码(其中包含差异注释的工作区版本或导致冲突的 HEAD 版本)后,差异窗口将打开。
这会在左侧显示您的本地代码,在右侧显示冲突的代码,您可以使用“下一个差异”按钮跳过所有冲突,并使用“从右向左复制更改”按钮接受远程版本,或者只需就地编辑您的本地版本即可。
一旦您对更改感到满意,请保存文件并添加它,然后提交结果,您就应该完成了。
请注意,我绝不是 git 良好实践的大师,所以如果这些不是最好使用的操作,请随时纠正我,但它是对“How do I do merge in eclipse with egit”问题的回答。
Just for reference, EGIT does now support merges and uses the powerful diff interface within eclipse.
Once you have fetched the code and run a merge, if there are any conflicts they are highlighted in the project explorer with a red !, you can then right click on them and go to Team > Merge Tool, which is un-ghosted for conflicted files.
Once you have selected the code you wish to use (Either the workspace version with diff annotations in it or the HEAD version that caused the conflict) the diff window will open.
This shows your local code on the left and the conflicting code on the right, you can use the 'next difference' button to jump through all the conflicts, and the 'copy change from right to left' button to accept the remote version, or simply edit your local version in place.
Once you are happy with the changes save your file and add it, then commit the results and you should be done.
Please note I am in no way a master of git good practice, so please feel free to correct me if these are not the best operations to use, but it was an answer to the question "How do I do merges in eclipse with egit".
使用 Eclipse 时,我只使用 egit 来实际提交。我只需通过命令行即可完成其他所有操作。 git(或任何其他 VCS)中的命令行要优越得多,并且该软件实际上是在考虑命令行的情况下创建的,因此很自然地,您可以通过命令行访问真正的每个功能。
其他一切仅在后台使用命令行,并尝试模拟主机应用程序本机的不同界面(此处:Eclipse)。但这样做永远无法达到与使用原始工具相同的能力。
不过我认为当 egit 进一步发展时,它可能是使用 git 的一个好方法;类似于 Eclipse 的 subversion 插件与大多数功能配合良好的方式。但在我的情况下,我不会使用 Eclipse 来完成所有事情,并且使用命令行比尝试习惯多个不同的插件和命令行要简单得多。
When working with Eclipse, I only use egit to actually commit. Everything else I do simply via the command line. The command line in git (or any other VCS) is much more superior and the software was actually created with having the command line in mind, so it's just naturally that you can access really every single feature via the command line.
Everything else only uses the command line in the background and tries to emulate a different interface, native to the host application (here: Eclipse). But by doing that you can never reach the same power as by using the original tools.
However I think when egit develops more, it might be a good way to work with git; similar to how the subversion plugin for Eclipse works well with most functions. But in my situation, I don't use Eclipse for everything and using the command line is then a lot simpler than trying to get used to multiple different plugins and the command line.
解决 Egit 合并冲突的一种方法是备份文件,从 eclipse 中删除它,将其从备份中放回,添加到索引并提交。
仅当您无法使用正常的“添加到索引”->“提交”方法解决冲突时,才应执行此操作。
PS:我假设您已经手动或使用 Egit 合并工具解决了冲突,但只是无法删除文件上的冲突标记。
One way to work out with Egit merge conflict is to take backup of your file, delete it from eclipse, put it back from backup, Add to index and commit.
This should be done only if you can't resolve the conflict with normal Add to Index->Commit method.
PS: I assume you've already resolved the conflict manually or by using Egit merge tool, but just can't remove the conflict marker on the file.