使用 EGit 将 eclipse 项目推送到 GitHub

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

Push eclipse project to GitHub with EGit

eclipsegithubegit

提问by salvador

I am successfully pushing my project to GitHub using EGit. My repository is called HelloWorld. My project in eclipse is also called HelloWorld. My problem is when i push the project it is upload the project under the folder HelloWorld. So the result is the repository HelloWorld then the folder HelloWorld and the the src folder. To be more understandable here is the linkof the project. I want under the repository HelloWorld to have the src folder. How can I achieve that?

我正在使用 EGit 成功地将我的项目推送到 GitHub。我的存储库名为 HelloWorld。我在 Eclipse 中的项目也称为 HelloWorld。我的问题是当我推送项目时,它会将项目上传到文件夹 HelloWorld 下。所以结果是存储库 HelloWorld 然后是文件夹 HelloWorld 和 src 文件夹。为了更容易理解,这里是项目的链接。我希望在存储库 HelloWorld 下有 src 文件夹。我怎样才能做到这一点?

回答by greenkode

The key lies in when you create the project in eclipse.

关键在于你什么时候在eclipse中创建项目。

First step, you create the Java project in eclipse. Right click on the project and choose Team > Share>Git.

第一步,在 eclipse 中创建 Java 项目。右键单击项目并选择Team > Share> Git

In the Configure Git Repository dialog, ensure that you select the option to create the Repository in the parent folder of the project.. enter image description hereThen you can push to github.

在 Configure Git Repository 对话框中,确保您选择了在项目的父文件夹中创建 Repository的选项. 在此处输入图片说明然后就可以推送到github了。

N.B: Eclipse will give you a warning about putting git repositories in your workspace. So when you create your project, set your project directory outside the default workspace.

注意:Eclipse 会警告您将 git 存储库放入您的工作区。因此,当您创建项目时,请将您的项目目录设置在默认工作区之外。

回答by Satya Tiwari

Simple Steps:

简单步骤:

-Open Eclipse.

- 打开日食。

  • Select Project which you want to push on github->rightclick.
  • select Team->share Project->Git->Create repository->finish.(it will ask to login in Git account(popup).
  • Right click again to Project->Team->commit. you are done
  • 在github上选择要推送的项目->右键单击。
  • 选择 Team->share Project->Git->Create repository->finish.(它会要求登录 Git 帐户(弹出)。
  • 再次右键单击 Project->Team->commit。 你完成了

回答by ZhaoGang

I have the same issue and solved it by reading this post, while solving it, I hitted a problem: auth failed.

我有同样的问题并通过阅读这篇文章解决了它,在解决它的同时,我遇到了一个问题:auth failed

And I finally solved it by using a ssh keyway to authorize myself. I found the EGit offical guidevery useful and I configured the sshway successfully by refer to the Eclipse SSH Configurationsection in the link provided.

我终于通过使用一种ssh key授权自己的方式解决了它。我发现EGit 官方指南非常有用,我ssh通过参考Eclipse SSH Configuration提供的链接中的部分成功配置了该方式。

Hope it helps.

希望能帮助到你。