集成 Eclipse 和 GitHub

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

Integrating Eclipse and GitHub

eclipsegithub

提问by Quaxton Hale

I am in need of help in trying to setup Eclipse so that I can push my code onto my GitHub account. I've searched online and the tutorials I have found are either outdated or don't work for me.

我在尝试设置 Eclipse 时需要帮助,以便我可以将代码推送到我的 GitHub 帐户。我在网上搜索过,发现的教程要么已经过时,要么对我不起作用。

I already have a project on Eclipse. How would I put that code onto GitHub? Would someone please add detailed instructions please. Any help is appreciated.

我已经在 Eclipse 上有一个项目。我如何将该代码放到 GitHub 上?请有人请添加详细说明。任何帮助表示赞赏。

EDITAs soon as I posted this question, and fiddling around with the settings I managed to get it to work! What a coincidence...

编辑一旦我发布了这个问题,并摆弄了设置,我就设法让它工作了!多么巧合...

The only problem I have now is how do I set it up so that when I commit it will only select the files in the project folder? Right now it is showing all 600 files in the Package Explorer.

我现在唯一的问题是如何设置它以便在提交时只选择项目文件夹中的文件?现在它在 Package Explorer 中显示了所有 600 个文件。

enter image description here

在此处输入图片说明

回答by Quaxton Hale

Alright, there are several ways of doing this. I found this to be the easiest way:

好的,有几种方法可以做到这一点。我发现这是最简单的方法:

First, set up SSH2 configurations. Go to Windows->Preferences->General->Network Connections->SSH2->Key Managementand Generate RSA Key. Save Key

首先,设置 SSH2 配置。转到Windows-> Preferences-> General-> Network Connections-> SSH2->Key ManagementGenerate RSA Key.Save Key

Copy that key. You will need to go to your GitHub account settings and add the new SSH key to your account.

复制那个键。您需要转到您的 GitHub 帐户设置并将新的 SSH 密钥添加到您的帐户。

Now, you need to install eGit:

现在,您需要安装 eGit:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

Next, you want to add the Git Repositories view:

接下来,您要添加 Git Repositories 视图:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

Create a new Git Repository. I have already created a repository called Java. I will refer to that repo for the rest of the explanation.

创建一个新的 Git 存储库。我已经创建了一个名为Java. 我将参考该 repo 进行其余的解释。

enter image description here

在此处输入图片说明

After you create your repository, it should show up in the Git Repositories view. Now to add your project to the repository, right click on your project and select Team->Share Project.

创建存储库后,它应该显示在 Git 存储库视图中。现在要将您的项目添加到存储库,右键单击您的项目并选择 Team->Share Project。

Select the repository you just created. You can also use CTRL+ to select multiple projects and place them in one repository.

选择您刚刚创建的存储库。您还可以使用 CTRL+ 来选择多个项目并将它们放在一个存储库中。

Now go back to your Git Repositories view. Go to Remotes. Right click and select Create Remote.

现在返回到您的 Git 存储库视图。转到遥控器。右键单击并选择创建远程。

enter image description here

在此处输入图片说明

Select Change...and enter the SSH link for your Repository on GitHub. For connection, select SSH. Then press Finish. enter image description hereFor Rev-mapping, select Advanced.... For Source Refselect refs/heads/master. And then press Add Spec, then select Save specifications in 'origin' configuration. Then press finish. That's pretty much it. You can commit changes by right clicking your project - >Team->Commit...`

Change...在 GitHub 上为您的存储库选择并输入 SSH 链接。对于连接,选择 SSH。然后按完成。 在此处输入图片说明对于 Rev-mapping,选择Advanced...。对于Source Ref选择refs/heads/master. 然后按Add Spec,然后选择Save specifications in 'origin' configuration. Then press finish. That's pretty much it. You can commit changes by right clicking your project - >Team ->Commit...`

enter image description here

在此处输入图片说明

Push new commits to GitHub:

将新提交推送到 GitHub:

enter image description here

在此处输入图片说明

This is a really good explanation on how to set up Eclipse pull requests.

这是关于如何设置 Eclipse 拉取请求的非常好的解释。

The current branch is not configured for pull No value for key branch.master.merge found in configuration

当前分支未配置为 pull 配置中找不到 key branch.master.merge 的值