如何在Eclipse中添加GitLab存储库? [英] How to add GitLab repository in Eclipse?

查看:95
本文介绍了如何在Eclipse中添加GitLab存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Eclipse上添加Git-Lab?

How to add Git-Lab on Eclipse?

这样我就可以从GitLab推送或获取。
我是这方面的新手,请给出更多解释。

So that I can just push or fetch from GitLab. I am a newbie in this, please give more explanation.

推荐答案

I准备



确保在Eclipse中具有eGit:

I Preparation

Make sure you have eGit in Eclipse:


  1. Help->安装详细信息

  2. 请确保列表中包含 Eclipse Git Team provider。

如果未安装,请按照中的指示进行操作。来自@VonC的 answer

If it is not installed, follow the indications in the answer from @VonC

请确保您具有URL到GitLab中的存储库。类似于 https://gitlab.com/<someusername>/<somerepository> 之类的东西,当您在项目的概述页面上时,可以从gitlab.com中获得它:

Make sure you have the URL to the repository in GitLab. Something like https://gitlab.com/<someusername>/<somerepository> You get it from gitlab.com when you are at the overview page for the project:


  • 菜单(汉堡图标≡,水平线3条),->项目,然后在eclipse中单击要使用的菜单。现在,您已进入概述页面。在项目名称及其描述的下面,有几个按钮可让您执行一些操作。这些按钮之一是SSH / HTTPS协议的选择器。现在,选择HTTPS并复制其后的URL:这是项目的URL。

这些步骤已在Eclipse Kepler和Eclipse Luna中进行了测试。有传言说它们已经过时了,可能无法按指示工作。如果您使用较新的Eclipse,请保重并回发新步骤:-)

These steps have been tested in Eclipse Kepler and Eclipse Luna. Rumor has it that they are outdated and might not work as indicated. If you use a newer Eclipse, take care and post back the new steps :-)


  1. Window-> Open Perspective-> Other

  2. 搜索 Git,将其选中,然后单击确定

  3. 单击带有箭头的按钮和工具提示克隆Git存储库并将克隆添加到此视图

  4. 在源Git存储库向导中:


    • URI:URL来自GitLab中的存储库,例如 https://gitlab.com/<someusername>//

    • eGit已填充

    • 保持连接不变(https,没有端口),并填写身份验证的详细信息:用于登录GitLab的用户名和密码.com。

    • 如果您勾选在安全存储中存储,那么Eclipse将从现在开始为您处理用户/密码。我可以,但是如果您与他人共享Eclipse安装,或者您不信任PC来保存密码,则不建议这样做。

    • 单击下一步

  1. Window -> Open Perspective -> Other
  2. Search for "Git", select it, and click "OK"
  3. Click the button with an arrow and the tool tip "Clone a Git repository and add the clone to this view"
  4. In the "Source Git Repository" wizard:
    • URI: the URL from the repository in GitLab, like https://gitlab.com/<someusername>/<somerepository>
    • eGit has filled in the host and repository path for you.
    • Leave the connection as it is (https and no port) and fill in the details for the authentication: user and password you use to log in GitLab.com.
    • If you tick the "Store in Secure Store," Eclipse will handle user/password for you from now on; I do it, but it is not advisable if you share Eclipse installation with someone else, or you do not trust your PC to hold your passwords.
    • Click next

  • 如果存储库中有多个分支,则可以选择要在本地克隆的分支,以及要与之交互的分支。您还可以选择克隆所有分支以使其可用。

  • 完成后,单击下一步


  • 您现在可以选择放置本地Git存储库的位置。 eGit默认为您用户下的一个子目录,与eclipse无关,它运行良好。如果您不喜欢它,请更改您的喜好。

  • 与其他Git安装一样,它将把GitLab.com存储库命名为 origin。

  • 在项目框中,选中导入所有项目,如果使用工作集,则现在可以选择其中一个放置它。

  • 单击完成。

  • You may now choose where you want to place your local Git repository. eGit defaults to a subdirectory under you user, unrelated to eclipse, it works well. If you do not like it, change to your liking.
  • As with other Git installations, it will name the GitLab.com repository as "origin". You may also change that if you really want.
  • In the projects box check the "Import all projects" and, if you work with "Working Sets", you may choose now in which one to place it.
  • Click Finish.

eGit现在可以工作一段时间,并在视图中向您显示新克隆的存储库。您有一个克隆的存储库,可以从Eclipse与之交互。

eGit now works for a bit and shows you the newly cloned repository in the view. You have a cloned repository with which you will be able to interact from Eclipse.


  1. 文件->导入...

  2. Git->来自Git的项目->下一步

  3. 现有本地存储库->下一步

  4. 选择新克隆的存储库->下一步

  5. 使用新建项目向导导入->完成

  6. 选择在GitLab.com中托管的项目类型。在我的情况下是 Java项目;在其他情况下,它是 Maven-> Maven项目。然后单击下一步

  7. 命名项目并更改所需的设置。作为目标,不要使用默认位置,而是导航到克隆的存储库的位置(如上一节克隆存储库中的步骤6所示)->下一步

  8. 确认导入看起来像您想要的,然后单击完成。

  1. File -> Import...
  2. Git -> Projects from Git -> Next
  3. Existing local repository -> Next
  4. Select the newly cloned repository -> Next
  5. Import using the New Project Wizard -> Finish
  6. Choose the project type that is hosted in GitLab.com. In my case is "Java Project;" in other occasions it has been "Maven -> Maven Project". Then click Next
  7. Name the project and change the settings you want. As destination, do not use the default location, but navigate to the location of the cloned repository (as used in step 6 in the previous section cloning the repository) -> Next
  8. Verify that the import looks like you want it and click Finish.

您现在可以在Eclipse中工作并使用团队了同步,提交和推送菜单。

You may now work within Eclipse and use the Team menus to sync and commit and push.

这篇关于如何在Eclipse中添加GitLab存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆