简体   繁体   English

如何在Eclipse中添加GitLab存储库?

[英]How to add GitLab repository in Eclipse?

How to add Git-Lab on Eclipse? 如何在Eclipse上添加Git-Lab?

So that I can just push or fetch from GitLab. 这样我就可以从GitLab中推送或获取。 I am a newbie in this, please give more explanation. 我是新手,请给出更多解释。

I Preparation 我准备

Make sure you have eGit in Eclipse: 确保你在Eclipse中有eGit:

  1. Help -> Installation details 帮助 - >安装细节
  2. See that "Eclipse Git Team provider" is in the list. 请参阅列表中的“Eclipse Git Team provider”。

If it is not installed, follow the indications in the answer from @VonC 如果未安装,请按照@VonC的答案中的指示进行操作

Make sure you have the URL to the repository in GitLab. 确保您拥有GitLab中存储库的URL。 Something like https://gitlab.com/<someusername>/<somerepository> You get it from gitlab.com when you are at the overview page for the project: https://gitlab.com/<someusername>/<somerepository>这样的东西当你在项目的概述页面时,你可以从gitlab.com获得它:

  • Menu (the hamburger icon ≡, 3 horizontal lines),-> projects, then click in the one you want to work with from eclipse. 菜单(汉堡包图标≡,3条水平线), - >项目,然后点击您要从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. 其中一个按钮是SSH / HTTPS协议的选择器。 For now, select HTTPS and copy the URL that follows it: that is the URL to the project. 现在,选择HTTPS并复制其后面的URL:这是项目的URL。

II Now clone the repository locally, using Eclipse eGit. II现在使用Eclipse eGit在本地克隆存储库。

These steps have been tested in Eclipse Kepler and Eclipse Luna. 这些步骤已在Eclipse Kepler和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 :-) 如果您使用较新的Eclipse,请注意并回发新步骤:-)

  1. Window -> Open Perspective -> Other 窗口 - >开放视角 - >其他
  2. Search for "Git", select it, and click "OK" 搜索“Git”,选择它,然后单击“确定”
  3. Click the button with an arrow and the tool tip "Clone a Git repository and add the clone to this view" 单击带箭头的按钮,工具提示“克隆Git存储库并将克隆添加到此视图”
  4. In the "Source Git Repository" wizard: 在“Source Git Repository”向导中:
    • URI: the URL from the repository in GitLab, like https://gitlab.com/<someusername>/<somerepository> URI:GitLab中存储库的URL,如https://gitlab.com/<someusername>/<somerepository>
    • eGit has filled in the host and repository path for you. eGit已经为您填写了主机和存储库路径。
    • 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. 保持连接不变(https和no port)并填写身份验证的详细信息:用于登录GitLab.com的用户和密码。
    • If you tick the "Store in Secure Store," Eclipse will handle user/password for you from now on; 如果勾选“在安全存储中存储”,Eclipse将从现在开始为您处理用户/密码; 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. 我这样做,但如果您与其他人共享Eclipse安装,或者您不相信您的PC保存您的密码,则不建议这样做。
    • 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. 您现在可以选择放置本地Git存储库的位置。 eGit defaults to a subdirectory under you user, unrelated to eclipse, it works well. eGit默认使用您用户下的子目录,与eclipse无关,效果很好。 If you do not like it, change to your liking. 如果您不喜欢它,请根据自己的喜好进行更改。
    • As with other Git installations, it will name the GitLab.com repository as "origin". 与其他Git安装一样,它将GitLab.com存储库命名为“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. eGit现在可以工作一段时间,并在视图中显示新克隆的存储库。 You have a cloned repository with which you will be able to interact from Eclipse. 您有一个克隆的存储库,您可以使用它与Eclipse进行交互。

III Now import the project into Eclipse. III现在将项目导入Eclipse。

  1. File -> Import... 文件 - >导入...
  2. Git -> Projects from Git -> Next Git - >来自Git的项目 - >下一步
  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. 选择GitLab.com中托管的项目类型。 In my case is "Java Project;" 在我的例子中是“Java Project;” in other occasions it has been "Maven -> Maven Project". 在其他场合,它一直是“Maven - > Maven项目”。 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 作为目标,不要使用默认位置,而是导航到克隆存储库的位置(如上一节中克隆存储库的步骤6中所使用 ) - >下一步
  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中工作并使用Team菜单进行同步,提交和推送。

The easiest way is to usean Eclipse with EGit ( http://www.vogella.com/tutorials/EclipseGit/article.html ) 最简单的方法是将Eclipse与EGit一起使用( http://www.vogella.com/tutorials/EclipseGit/article.html

See " Compare Eclipse packages " (the standard Eclipse , for instance, has EGit) 请参阅“ 比较Eclipse包 ”(例如, 标准Eclipse具有EGit)

This will allow you to add a remote repo url referring to your gitlab repo hosting server. 这将允许您添加一个远程repo url引用您的gitlab repo托管服务器。
This isn't specific to gitlab though, and you could add remote repos referring to Github or Bitbucket. 这不是特定于gitlab,你可以添加远程repos引用Github或Bitbucket。
http://wiki.eclipse.org/EGit/User_Guide#Working_with_remote_Repositories http://wiki.eclipse.org/EGit/User_Guide#Working_with_remote_Repositories

http://wiki.eclipse.org/images/3/35/Egit-0.9-clone-wizard-url-page.png

It seems that there is a Mylyn Gitlab Connector now. 现在似乎有一个Mylyn Gitlab连接器

I think I'll give it a try 我想我会尝试一下

使用从http://download.eclipse.org/egit/updates安装新软件在eclipse中安装Egit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM