如何将 Eclipse 项目工作区与 Git-BitBucket 同步?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42679955/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:39:29  来源:igfitidea点击:

How to synchronize Eclipse project workspace with Git-BitBucket?

eclipsegit

提问by zendu

I am new to Eclipse as well as Git world. Following question may sound like really dumb thing to ask, but I have spent hours finding how to do it and found no way.

我是 Eclipse 和 Git 世界的新手。以下问题可能听起来很愚蠢,但我花了几个小时寻找如何去做却没有找到办法。

We have a Git remote repository that I have cloned using Eclipse's Git perspective. My team makes some changes to code and pushes them to remote repository. I am stuck with "getting latest" code in my local workspace.

我们有一个 Git 远程存储库,我使用 Eclipse 的 Git 透视图克隆了它。我的团队对代码进行了一些更改并将它们推送到远程存储库。我被困在我的本地工作区中“获取最新”代码。

Here is what I tried: Open Java EE perspective. Right click on my project -> Team -> Synchronize Workspace. This opens "Team Synchronizing" perspective. It shows me that there are some "incoming" files, but there is no option to "get" them. Only options I see are Merge, Overwrite, Commit. Well, none of them make sense to me.

这是我尝试过的:打开 Java EE 透视图。右键单击我的项目 -> 团队 -> 同步工作区。这将打开“团队同步”透视图。它告诉我有一些“传入”文件,但没有“获取”它们的选项。我看到的唯一选项是合并、覆盖、提交。好吧,它们对我来说都没有意义。

In TFS world, I just select "get latest" and new versions replace old versions in local workspace. What am I missing?

在 TFS 世界中,我只选择“获取最新版本”,新版本替换本地工作区中的旧版本。我错过了什么?

回答by VonC

The Synchronize Viewwill only allow you to inspect the differences between the resources in the local workspace and a local or remote tracking branch.

同步视图将只允许你检查资源之间在本地工作区和本地或远程跟踪分行的差异。

It won't get the last commits.

它不会得到最后的提交。

For that, you need to pull new changes from the upstream branch

为此,您需要从上游分支中提取新的更改

Right-click on a project in the Package Explorerand select Team > Pullor right-click on a repository in the Git Repositories view and select Pullto pull new changes from the upstream branch your local branch is tracking.
This also works if resources are selected from more than one repository.

右键单击 中的项目,然后在 Git 存储库视图中Package Explorer选择Team > Pull或右键单击存储库,然后选择Pull从本地分支正在跟踪的上游分支中提取新更改。
如果资源是从多个存储库中选择的,这也适用。

See for instance "EGit Auto-Merge and Conflict Resolution "

参见例如“ EGit Auto-Merge and Conflict Resolution

https://wiki.52north.org/pub/Documentation/ResolveMergeConflictsInGitEclipse/egit_merge_2.png

https://wiki.52north.org/pub/Documentation/ResolveMergeConflictsInGitEclipse/egit_merge_2.png

To understand more about that workflow, look at GIT Illustrated Cheatsheet -- Working with remote repositories

要了解有关该工作流程的更多信息,请查看GIT Illustrated Cheatsheet -- Working with remote repositories

https://illustrated-git.readthedocs.io/en/latest/_images/git-flows.svg

https://illustrated-git.readthedocs.io/en/latest/_images/git-flows.svg