{"id":730,"date":"2015-10-07T03:06:23","date_gmt":"2015-10-07T01:06:23","guid":{"rendered":"http:\/\/hobbykeller.spdns.de\/?p=730"},"modified":"2021-01-19T21:12:32","modified_gmt":"2021-01-19T20:12:32","slug":"using-gitolite-with-eclipse","status":"publish","type":"post","link":"https:\/\/hobbykeller.spdns.de\/?p=730","title":{"rendered":"Using gitolite with Eclipse"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-731\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/egit_logo.png\" alt=\"egit_logo\" width=\"85\" height=\"76\" \/>Unfortunately, the versatility which comes with Eclipse&#8217;s EGit plugin makes it also quite complex. Maybe for those who use conventional git servers such as github or bitbucket EGit is self-explanatory but if the quirks of EGit as a git interface come together with the particularities of gitolite as an add-on to the git server, obstacles begin to pop up which are not covered in the standard howtos on EGit or gitolite. While <a href=\"http:\/\/hobbykeller.spdns.de\/?p=718\">my previous blog on gitolite<\/a> covered the server side, this blog is intended to describe what is necessary on the user side.<\/p>\n<p><!--more--><\/p>\n<h1>1. Preparing Eclipse<\/h1>\n<h2>Direct Eclipse to the correct ssh keys<\/h2>\n<ul>\n<li>Launch your Eclipse IDE,<\/li>\n<li>click <code>Window<\/code> \/ <code>Preferences<\/code> \/ <code>Network<\/code> \/ <code>SSH2<\/code><\/li>\n<li>enter the SSH2 home directory (in case of the &#8220;admin &amp; gitolite user scenario&#8221; from step 1 <code>~\/.eclipse_ssh\/<\/code> otherwise just the standard <code>~\/.ssh<\/code> directory),<\/li>\n<li>open the <code>Key Management<\/code> tab, click <code>Load Existing Key...<\/code> and select the private <code>id_rsa<\/code> key from the respective SSH2 home directory<\/li>\n<\/ul>\n<figure id=\"attachment_732\" aria-describedby=\"caption-attachment-732\" style=\"width: 794px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_ssh_general.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-732\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_ssh_general.png\" alt=\"Setting the SSH home in Eclipse for use with gitolite\" width=\"794\" height=\"423\" srcset=\"https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_ssh_general.png 794w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_ssh_general-300x160.png 300w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_ssh_general-500x266.png 500w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/a><figcaption id=\"caption-attachment-732\" class=\"wp-caption-text\">Setting the SSH home in Eclipse for use with gitolite<\/figcaption><\/figure>\n<h2>Add Git Views To Eclipse<\/h2>\n<ul>\n<li>Click <code>Window<\/code> \/ <code>Show View<\/code> in the Eclipse main menu,<\/li>\n<li>click <code>Other<\/code>, then expand <code>Git<\/code> and select <code>Git Repositories<\/code> and <code>Staging Area<\/code>.<\/li>\n<li>Click <code>Windows<\/code> \/ <code>Show View<\/code> again and then expand <code>Team<\/code> and select <code>History<\/code><\/li>\n<\/ul>\n<h2>Add Git Toolbar<\/h2>\n<ul>\n<li>Click <code>Window<\/code> \/ <code>Perspective<\/code> \/ <code>Customize Perspective<\/code><\/li>\n<li>Select tab <code>Action Set Availability<\/code><\/li>\n<li>Select <code>Git<\/code> and click <code>OK<\/code><\/li>\n<li>If necessary reposition the toolbar to an appropriate location<\/li>\n<\/ul>\n<figure id=\"attachment_733\" aria-describedby=\"caption-attachment-733\" style=\"width: 359px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-733\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/egit_toolbar.png\" alt=\"EGit menu toolbar\" width=\"359\" height=\"32\" srcset=\"https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/egit_toolbar.png 359w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/egit_toolbar-300x27.png 300w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><figcaption id=\"caption-attachment-733\" class=\"wp-caption-text\">EGit menu toolbar<\/figcaption><\/figure>\n<h2>Put your gitolite keys on the client machine in a separate directory<code><br \/>\n<\/code><\/h2>\n<p><em>This step will only be necessary if you do not access the repo by your default ssh key. This is normally the case if you are both the (general) server admin who has root access through your default ssh key <strong>and<\/strong> gitolite user who needs a seperate ssh key to access the gitolite shell. In case you are only a gitolite user, you can work with your default keys and skip this step. <\/em><\/p>\n<p>As the ssh key presented to the server provides both identification and access authorization to the git services underlying gitolite, it is important to make sure that Eclipse fetches the proper key set.<\/p>\n<p>My experience is that at some point in the git process, Eclipse obstinately tries to use the default <code>id_rsa<\/code> key pair in your <code>~\/.ssh<\/code> directory even if told to use another key in that directory. The easiest way to reliably prevent this is to create a separate <code>~\/.eclipse_ssh<\/code> directory and symlink the proper key pair into that directory:<\/p>\n<pre class=\"lang:default decode:true\" title=\"Symlinking git's ssh keys into seperate diectories\">user@client:~$ mkdir ~\/.eclipse_ssh\r\nuser@client:~$ ln -f ~\/.ssh\/id_rsa_git ~\/.eclipse_ssh\/id_rsa\r\nuser@client:~$ ln -f ~\/.ssh\/id_rsa_git.pub ~\/.eclipse_ssh\/id_rsa.pub\r\n<\/pre>\n<h1>2. Create and push a new repository<\/h1>\n<p>These instructions are derived from a <a href=\"https:\/\/www.youtube.com\/watch?v=r5C6yXNaSGo&amp;index=2&amp;list=PL-suslzEBiMo0B5RcAikOaqDLKoG9Okub\" target=\"_blank\" rel=\"noopener\">YouTube tutorial by Brian Fraser<\/a> which assumes you want to put code into a repository on github.com. In our case with a gitolite server, the tutorial&#8217;s instructions have to be slightly amended.<\/p>\n<p>For the sake of simplicity, we assume that you have created some Eclipse Hello World project locally which you eventually want to push to the gitolite server.<\/p>\n<h2>Produce a local repository<\/h2>\n<p>The first step is always to create a local repository which you can later push to your gitolite server:<\/p>\n<ul>\n<li>In the <code>Package Explorer<\/code> Window, navigate to the Top of your Project<\/li>\n<li>right click and select <code>Team<\/code> \/ <code>Share<\/code> project form the context dialog<\/li>\n<li>click <code>Create...<\/code> and enter the location and name for the local repository (e.g. <code>\/home\/user\/git\/HelloWorldRepo<\/code>)<\/li>\n<\/ul>\n<figure id=\"attachment_734\" aria-describedby=\"caption-attachment-734\" style=\"width: 554px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_config.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-734\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_config.png\" alt=\"EGit repository configuration\" width=\"554\" height=\"333\" srcset=\"https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_config.png 554w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_config-300x180.png 300w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_config-500x300.png 500w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/a><figcaption id=\"caption-attachment-734\" class=\"wp-caption-text\">EGit repository configuration<\/figcaption><\/figure>\n<p>After hitting the <code>Finish<\/code> button your repo will be created and your project will be moved to the &#8211; locally created &#8211; git repository directory you just specified.<\/p>\n<h2>Commit initial checkin<\/h2>\n<ul>\n<li>Right click the top of your Project in the Package Explorer<\/li>\n<li>Select <code>Team<\/code> \/ <code>Commit<\/code><\/li>\n<li>In the <code>Commit Changes<\/code> dialog which pops up, enter a commit message<\/li>\n<li>In the <code>Files<\/code> list, select everything except the compiled <code>class<\/code> files<\/li>\n<li>Click <code>Commit<\/code><\/li>\n<\/ul>\n<p>In the Git Repositories panel you will see that the repository now changed to the master branch.<\/p>\n<h2>Create an empty repository on the remote<\/h2>\n<p>You need to have an empty repository to which you can push on the remote which you can create as follows:<\/p>\n<p>Clone the <code>gitolite-admin<\/code> repo to your local machine (you need to be the gitolite admin for this):<\/p>\n<pre class=\"lang:default decode:true\" title=\"Configuration of gitolite\">git clone root@git:gitolite-admin\r\ncd gitolite-admin\/conf<\/pre>\n<p>Edit the <code>gitolite.conf<\/code> file by adding a section for the new repository to be created. In case your repository should be called <code>myrepo<\/code> and offer complete access to the user <code>santa<\/code> on the server, add a section which looks like the following:<\/p>\n<pre class=\"lang:default decode:true\" title=\"Creating a new repo\">repo gitolite-admin\r\n    RW+     =   admin\r\n\r\nrepo myrepo\r\n    RW+     =   santa\r\n<\/pre>\n<p>You than need to add, commit and push on the changes to the gitolite server:<\/p>\n<pre class=\"lang:default decode:true \" title=\"Pushing a new config to gitolite\">git add gitolite.conf\r\ngit commit -m \"Added new repo myrepo for user santa\"\r\ngit push origin master<\/pre>\n<p>gitolite will automatically check if the amended repository exists on the server. If this is not the case, it will automatically create and initialize the repository and you should read something as follows:<\/p>\n<pre class=\"lang:default decode:true\" title=\"New repository after gitolite.conf is pushed to the server\">Counting objects: 4, done.\r\nDelta compression using up to 8 threads.\r\nCompressing objects: 100% (3\/3), done.\r\nWriting objects: 100% (4\/4), 398 bytes | 0 bytes\/s, done.\r\nTotal 4 (delta 0), reused 0 (delta 0)\r\nremote: Initialized empty Git repository in \/root\/repositories\/myrepo.git\/\r\n<\/pre>\n<p>That&#8217;s it &#8211; your empty repo has been created on the server. There is a bunch of different methods presented on other websites. My experience is that following such methods will at best fail to work (such as the one presented here which may be outdated) or at worst damage your server (such as the attempt to <a href=\"http:\/\/gitolite.com\/gitolite\/basic-admin.html\" target=\"_blank\" rel=\"noopener\">manually add users and repos<\/a> on the server). &#8211; My advice is to stay on the safe side and let gitolite automatically create new repos by cloning the <code>gitolite-admin<\/code> repo, editing its <code>gitolite.conf<\/code> file and pushing it back to the server.<\/p>\n<h2>Push the repo to the server<\/h2>\n<p>You are now ready to push the repo to your server.<\/p>\n<ul>\n<li>Right click your repository in the <code>Git Repositories<\/code> panel<\/li>\n<li><code>Choose Team<\/code> \/ <code>Push Branch master<\/code><\/li>\n<li>Fill in the dialogue as shown below:<\/li>\n<li>Hit <code>Next<\/code> and <code>Finish<\/code> in the following dialogue<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-748\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git-push.png\" alt=\"eclipse_git-push\" width=\"613\" height=\"582\" srcset=\"https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git-push.png 613w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git-push-300x285.png 300w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git-push-316x300.png 316w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/li>\n<\/ul>\n<h1>Cloning a repository from the remote<\/h1>\n<ul>\n<li>Click <code>Clone a Git repository<\/code> in the <code>Git Repositories<\/code> pane<\/li>\n<li>Fill in the dialogue using the same settings as shown in the previous section on pushing the repository to the git server and click <code>Next <\/code><\/li>\n<li>Click through the following dialogues &#8211; usually it is sufficient to just confirm the default settings<\/li>\n<\/ul>\n<p>The repo will now appear in your Git Repositories pane &#8211; but in order to work with the files in the IDE, you still have to import the repository:<\/p>\n<ul>\n<li>Right-click on the repo in the repositories pane and choose <code>Import Project<\/code><\/li>\n<li>Select the folder you want to import and click <code>Next<\/code> <a href=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-750\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_import.png\" alt=\"eclipse_git_import\" width=\"600\" height=\"479\" srcset=\"https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_import.png 600w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_import-300x240.png 300w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_import-376x300.png 376w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<li>Leave the default settings in the following dialogue and click <code>Finish<\/code><\/li>\n<\/ul>\n<h1>Pushing changes to the git server<\/h1>\n<p>Once you have imported the remote repository it will appear in your <code>Package Explorer<\/code> pane. For the sake of example, we will change the message which is sent to the console by the <code>println()<\/code> statement in the <code>HelloWorld.java<\/code> example by changing the message &#8220;Hello World&#8221; to &#8220;Hallo Welt&#8221;.<\/p>\n<p>Once you have saved your changes, you will see that the file appears in the <code>Unstaged Changes<\/code> section in your <code>Git Staging<\/code> pane.<\/p>\n<figure id=\"attachment_751\" aria-describedby=\"caption-attachment-751\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_staging.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-751\" src=\"http:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_staging.png\" alt=\"Git Staging pane\" width=\"600\" height=\"248\" srcset=\"https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_staging.png 600w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_staging-300x124.png 300w, https:\/\/hobbykeller.spdns.de\/wp-content\/uploads\/2015\/10\/eclipse_git_staging-500x207.png 500w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-751\" class=\"wp-caption-text\">Git Staging pane<\/figcaption><\/figure>\n<ul>\n<li>Drag &amp; drop the files from the <code>Unstaged Changes<\/code> to the <code>Staged Changes<\/code> area<\/li>\n<li>Enter a commit message like &#8220;Changed the language in the Hello World prompt&#8221;<\/li>\n<li>And click <code>Commit and Push<\/code> (which will transfer the changes directly into the remote repo) or just <code>Commit<\/code> (which will only affect your local copy of the repository)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Unfortunately, the versatility which comes with Eclipse&#8217;s EGit plugin makes it also quite complex. Maybe for those who use conventional git servers such as github or bitbucket EGit is self-explanatory<span class=\"more-button\"><a href=\"https:\/\/hobbykeller.spdns.de\/?p=730\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Using gitolite with Eclipse<\/span><\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64,16],"tags":[137,138,139,140],"class_list":["post-730","post","type-post","status-publish","format-standard","hentry","category-linux","category-openwrt","tag-eclipse","tag-egit","tag-gitloite","tag-repo"],"_links":{"self":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=730"}],"version-history":[{"count":11,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":1343,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions\/1343"}],"wp:attachment":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}