git 使用 GitHub 和 Eclipse 拉取代码

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

Using GitHub and Eclipse to pull code

eclipsegitgithub

提问by Alexander Mills

I have a repo on GitHub here.

在 GitHub 上有一个 repo here

I have pushed to this repo from two different machines, so now one machine is current and another has outdated code. Right now, I am on the machine with outdated code, and I want to pull in the master/HEAD/whatever from GitHub.

我已经从两台不同的机器推送到这个 repo,所以现在一台机器是最新的,另一台机器的代码已经过时。现在,我在使用过时代码的机器上,我想从 GitHub 中提取 master/HEAD/whatever。

And then I get to stare at this:

然后我开始盯着这个:

enter image description here

在此处输入图片说明

I do not want to do something stupid like delete the project from Eclipse and then pull in all the code from GitHub.

我不想做一些愚蠢的事情,比如从 Eclipse 中删除项目,然后从 GitHub 中提取所有代码。

Can someone please help me merge/synchronize the projects? This is as simple as it sounds.

有人可以帮我合并/同步项目吗?这听起来很简单。

Unfortunately, this is what happens when I click "Pull" on the above menu:

不幸的是,当我在上面的菜单上单击“拉”时会发生这种情况:

enter image description here

在此处输入图片说明

Would someone also explain what the difference is between Pull, Merge, Fetch and Synchronize?

有人会解释拉、合并、提取和同步之间的区别吗?

采纳答案by Eugene Ryzhikov

eGit doesn't know, which remote branch you want to pull from. If you create your local branch based on a remote tracking branch, then the key is generated automatically. Otherwise you have to create it yourself:

eGit 不知道你想从哪个远程分支中拉取。如果您基于远程跟踪分支创建本地分支,则会自动生成密钥。否则你必须自己创建它:

branch.master.merge=refs/heads/master
branch.master.remote=origin

where master stands for the branchname, in the key it's your local branch, in the value it's the branch in the remote repository. Place that in the repository-specific configuration file %repositorypath%\.git\config

其中 master 代表branchname,在键中它是您的本地分支,在值中它是远程存储库中的分支。将其放在特定于存储库的配置文件中%repositorypath%\.git\config

As for the terms:

至于条款:

  • merge: join two or more development histories together
  • fetch: download objects and refs from another repository
  • pull: fetch from and merge with another repository or local branch
  • sync: allows you to compare 2 branches
  • merge: 将两个或多个开发历史连接在一起
  • fetch:从另一个存储库下载对象和引用
  • pull: 从另一个存储库或本地分支获取并合并
  • sync: 允许您比较 2 个分支

In general, I urge you to read eGit user guide, where you can get even better understanding of Git and eGit. It can be found at http://wiki.eclipse.org/EGit/User_Guide

总的来说,我强烈建议您阅读 eGit 用户指南,在那里您可以更好地了解 Git 和 eGit。它可以在http://wiki.eclipse.org/EGit/User_Guide找到