Git 工作目录到 Eclipse 工作区

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

Git Working Directory to Eclipse Workspace

eclipsegitgithubegit

提问by totalcruise

I have been building my maven project(s) within my spring tool suite work space and have now decided that I need to get busy with some version control.

我一直在我的 spring 工具套件工作空间中构建我的 maven 项目,现在决定我需要忙于一些版本控制。

I have gone for GIT and have used the command line client to produce a local repository.

我选择了 GIT 并使用命令行客户端来生成本地存储库。

So, I have a local repo - which is ready to implements version control and a workspace with a load of files.

所以,我有一个本地存储库 - 它准备好实现版本控制和一个带有大量文件的工作区。

I am using the GIT plugin for Eclipse. See the image below.

我正在为 Eclipse 使用 GIT 插件。见下图。

enter image description here

在此处输入图片说明

How am I able to somehow synchronise my workspace with my git working directory so I can start to stage and commit indexes to Github?

我如何能够以某种方式将我的工作区与我的 git 工作目录同步,以便我可以开始暂存并将索引提交到 Github?

Many thanks

非常感谢

//** EDIT **//

//** 编辑 **//

Okay - having found thisblog

好的 - 找到了这个博客

I realized it is a simple project->team->share project option in the Eclipse Project Context Menu.

我意识到这是 Eclipse 项目上下文菜单中的一个简单的项目->团队->共享项目选项。

Thanks

谢谢

采纳答案by VonC

This blog post(from Lucas Piva Rocha Corrêa) details the step you need to follow to share your local git project on GitHub;

这篇博文(来自Lucas Piva Rocha Corrêa)详细介绍了在 GitHub 上共享本地 git 项目所需遵循的步骤;

  • that includes the "Team Share" you found
  • but it also mentions the ssh settings you need to get right in order to be able to push to an https GitHub address.
  • 包括您找到的“团队共享”
  • 但它也提到了正确的 ssh 设置,以便能够推送到 https GitHub 地址。

Configuring Eclipse

配置 Eclipse

  • Go to Windows -> Preferencesand filter SSH. Select SSH2on the left tab (should be under General -> Network connections).
  • Check that SSH2home is set to /home/<yourusername>/.sshand id_rsais in Private Keys.
  • On Key Managementtab, click on Load Existing Key... and select your id_rsa(private) key under ~/.ssh/id_rsa. If your key has a non-empty passphrase, eclipse will not be able to load it, even if you provide the correct password.
  • Now, just save it in the same location you loaded it from, confirm empty passphrase, overwrite it, apply and click ok.
  • 转到Windows -> Preferences并过滤 SSH。SSH2在左侧选项卡上选择(应该在“常规”->“网络连接”下)。
  • 检查SSH2home 是否设置为/home/<yourusername>/.sshid_rsa在 Private Keys 中。
  • Key Management选项卡上,单击Load Existing Key... 并id_rsa在 下选择您的(私人)密钥~/.ssh/id_rsa。如果您的密钥有一个非空密码,即使您提供了正确的密码,eclipse 也无法加载它。
  • 现在,只需将其保存在您加载它的同一位置,确认空密码,覆盖它,应用并单击确定。

Pushing your project to your github repo

将你的项目推送到你的 github 仓库

Final step is to push your project to your remote repository on github.

  • Finally, select the project you want to push to your created repository, right click it, go to Team -> Share Project... and select git.
  • Select your project, click on Create Repository and Finish. Now you should be able to commit and update changes to your local git repository.
  • To push it to your remote GitHub repo, right click your project, select Team -> Remote -> Push...
  • Fill the URI with your project SSH address, which is shown when you enter your repository page on GitHub.
  • Select ssh protocol, user is gitand empty password.
  • Cross your fingers, hit next. If it doesn't work for some reason at this point, try restarting Eclipse (it worked for me after restart).
  • Select Source Ref and Destination Ref (basically the branch), click on Add Spec and Finish on the next screen.
  • Hopefully everything goes well.

最后一步是将您的项目推送到 github 上的远程存储库。

  • 最后,选择要推送到创建的存储库的项目,右键单击它,转到Team -> Share Project... 并选择git
  • 选择您的项目,单击创建存储库并完成。现在您应该能够提交和更新对本地 git 存储库的更改。
  • 要将其推送到您的远程 GitHub 存储库,请右键单击您的项目,选择Team -> Remote -> Push...
  • 使用您的项目 SSH 地址填充 URI,当您在 GitHub 上输入您的存储库页面时会显示该地址。
  • 选择ssh protocol,用户是git和空密码。
  • 交叉你的手指,点击下一个。如果此时由于某种原因它不起作用,请尝试重新启动 Eclipse(重新启动后它对我有用)。
  • 选择 Source Ref 和 Destination Ref(基本上是分支),在下一个屏幕上单击 Add Spec 和 Finish。
  • 希望一切顺利。