如何在Eclipse上添加GitLab? [英] How to add GitLab on Eclipse?

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

问题描述

如何在Eclipse上添加Git-Lab?所以我可以直接从Git-Lab推送或获取。
我是一个新手,所以我需要更多的解释。



谢谢。

解决方案

我准备



确保你在Eclipse中有eGit:


  1. 帮助 - >安装细节

  2. 看到Eclipse Git Team provider在列表中。

如果没有安装,请按照@VonC中的答案中的指示/ p>

确保您具有GitLab中存储库的URL。像 https://gitlab.com/<someusername>/<somerepository> 当您在项目概述页面时,您可以从gitlab.com获取它:




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



II现在克隆存储库,使用Eclipse eGit。



这些步骤已在Eclipse Kepler和Eclipse Luna中测试过。谣言说,他们已经过时了,可能无法正常工作。如果您使用较新的Eclipse,请小心并发布新的步骤: - )


  1. 窗口 - >打开透视图 - >其他

  2. 搜索Git,选择它,然后单击确定

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

  4. 在源代码存储库向导中:


    • URI:URL从GitLab的存储库,如 https://gitlab.com/<someusername>/<somerepository>

    • eGit有填写您的主机和存储库路径。

    • 将连接保持原样(https和无端口),并填写验证的详细信息:用于登录的用户和密码GitLab.com。

    • 如果您勾选Store in Secure Store,Eclipse会从现在开始处理您的用户/密码;我这样做,但是如果您与其他人共享Eclipse安装,或者您不信任您的PC来保存密码是不可取的。

    • 点击下一步


  5. 分支选择向导。


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

    • 完成后,单击下一步


  6. 本地目标向导。


    • 您现在可以选择要放置本地Git仓库的位置。 eGit默认为用户下的子目录,与eclipse无关,它工作得很好。如果您不喜欢,请更改为您的喜好。

    • 与其他Git安装一样,它将将GitLab.com存储库命名为origin。如果您真的想要,您也可以更改。

    • 在项目框中,选中导入所有项目,如果使用工作集,您现在可以选择哪一个

    • 单击完成。


eGit现在可以工作,并在视图中显示新克隆的存储库。您有一个克隆的存储库,您可以使用它们与Eclipse进行交互。



III现在将项目导入Eclipse。




  1. 文件 - >导入...

  2. Git - > Git项目 - >下一步

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

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

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

  6. 选择在GitLab.com中托管的项目类型。在我的例子中是Java Project在其他场合,它一直是Maven - > Maven项目。然后单击下一步

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

  8. 验证导入是否像您想要的那样,然后单击完成。

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


How to add Git-Lab on Eclipse? So that I can just push or fetch from Git-Lab. I am a newbie in this, so I kinda need more explanation.

Thank you.

解决方案

I Preparation

Make sure you have eGit in Eclipse:

  1. Help -> Installation details
  2. See that "Eclipse Git Team provider" is in the list.

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

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:

  • Menu (the hamburger icon ≡, 3 horizontal lines),-> projects, then click in the one you want to work with from eclipse. Now you are in the overview page. Right beneath the name of the project and its description there are a few buttons to allow you to perform some actions. One of those buttons is a selector for SSH/HTTPS protocols. For now, select HTTPS and copy the URL that follows it: that is the URL to the project.

II Now clone the repository locally, using Eclipse eGit.

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. Search for "Git", select it, and click "OK"
  3. Click the button with the blue 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
  5. Branch selection wizard.
    • If there are more than one branch in the repository, you may now choose which one you want to clone locally, the one with which you want to interact. You may also choose to clone all branches to have them available.
    • Once you are done, click Next
  6. Local destination wizard.
    • 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 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.

III Now import the project into Eclipse.

  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.

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

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

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