Files
i2p.www/i2p2www/pages/site/docs/applications/git.html

100 lines
8.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "global/layout.html" %}
{% block title %}{% trans %}Setting up Gitlab with I2P{% endtrans %}{% endblock %}
{% block lastupdated %}2020-09{% endblock %}
{% block accuratefor %}0.9.47{% endblock %}
{% block content %}
<h1 id="git-over-i2p-for-users">Git over I2P for Users</h1>
<p>{% trans -%} Tutorial for setting up git access through an I2P Tunnel. This tunnel will act as your access point to a single git service on I2P. {%- endtrans %}</p>
<b>{% trans -%} If you intend to use the service at i2pgit.org/git.idk.i2p, then you probably already have a tunnel configured and much of this
tutorial will not apply to you.{%- endtrans %}</b>
<h2 id="first-set-up-an-account-at-a-git-service">First: Set up an account at a Git service</h2>
<p>{% trans -%} To create your repositories on a remote git service, sign up for a user account at that service. Of course its also possible to create repositories locally and push them to a remote git service, but most will require an account and for you to create a space for the repository on the server. Gitlab has a very simple sign-up form: {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/register.png" alt="" /><figcaption>Registration is easy!</figcaption>
</figure>
<h2 id="second-create-a-project-to-test-with">Second: Create a project to test with</h2>
<p>{% trans -%} To make sure the setup process works, it helps to make a repository to test with from the server, and for the sake of this tutorial, were going to use a fork of the I2P router. First, browse to the i2p-hackers/i2p.i2p repository: {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/explore.png" alt="" /><figcaption>Browse to i2p.i2p</figcaption>
</figure>
<figure>
<img src="/_static/images/git/i2p.png" alt="" /><figcaption>I2P Hackers i2p.i2p</figcaption>
</figure>
<p>{% trans -%} Then, fork it to your account. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/fork.png" alt="" /><figcaption>Roger is forking</figcaption>
</figure>
<figure>
<img src="/_static/images/git/forked.png" alt="" /><figcaption>Roger is finished</figcaption>
</figure>
<h2 id="third-set-up-your-git-client-tunnel">Third: Set up your git client tunnel</h2>
<p>{% trans -%} To have read-write access to my server, youll need to set up a tunnel for your SSH client. As an example, were going to use the HTTP tunnel instead, but if all you need is read-only, HTTP/S cloning, then you can skip all this and just use the http_proxy environment variable to configure git to use the pre-configured I2P HTTP Proxy. For example: {%- endtrans %}</p>
<pre><code>http_proxy=http://localhost:4444 git clone http://gittest.i2p/i2p-developer/i2p.i2p</code></pre>
<figure>
<img src="/_static/images/git/wizard1.png" alt="" /><figcaption>Client tunnel</figcaption>
</figure>
<figure>
<img src="/_static/images/git/wizard2.png" alt="" /><figcaption>Git over I2P</figcaption>
</figure>
<p>{% trans -%} Then, add the address you will be pushing and pulling from. Note that this example address is for Read-Only HTTP-over-I2P clones, if your admin does not allow the git HTTP(Smart HTTP) protocol, then you will need to get the SSH clone base32 from them. If you have an SSH clone base32, substitute it for the base32 in this step, which will fail. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/wizard3.png" alt="" /><figcaption>gittest.i2p</figcaption>
</figure>
<p>{% trans -%} Pick a port to forward the I2P service to locally. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/wizard4.png" alt="" /><figcaption>localhost:localport</figcaption>
</figure>
<p>{% trans -%} I use it alot, so I start my client tunnel automatically, but its up to you. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/wizard5.png" alt="" /><figcaption>Auto Start</figcaption>
</figure>
<p>{% trans -%} When youre all done, it should look alot like this. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/wizard6.png" alt="" /><figcaption>Review settings</figcaption>
</figure>
<h2 id="trans--fourth-attempt-a-clone--endtrans">{% trans -%}Fourth: Attempt a clone{%- endtrans %}</h2>
<p>{% trans -%}Now your tunnel is all set up, you can attempt a clone over SSH.{%- endtrans %}</p>
<pre><code>GIT_SSH_COMMAND=&quot;ssh -p 7442&quot; \
git clone git@127.0.0.1:i2p-developer/i2p.i2p</code></pre>
<p>{% trans -%} You might get an error where the remote end hangs up unexpectedly. Unfortunately git still doesnt support resumable cloning. Until it does, there are a couple fairly easy ways to handle this. The first and easiest is to try and clone to a shallow depth: {%- endtrans %}</p>
<pre><code>GIT_SSH_COMMAND=&quot;ssh -p 7442&quot; \
git clone --depth 1 git@127.0.0.1:i2p-developer/i2p.i2p</code></pre>
<p>{% trans -%} Once youve performed a shallow clone, you can fetch the rest resumably by changing to the repo directory and running: {%- endtrans %}</p>
<pre><code>git fetch --unshallow</code></pre>
<p>{% trans -%} At this point, you still dont have all your branches yet. You can get them by running the following commands: {%- endtrans %}</p>
<pre><code>git config remote.origin.fetch &quot;+refs/heads/*:refs/remotes/origin/*&quot;
git fetch origin</code></pre>
<p>{% trans -%} Which tells git to alter the repository configuration so that fetching from origin fetches all branches. {%- endtrans %}</p>
<p>{% trans -%} If that doesnt work, you can try opening the tunnel configuration menu and adding some backup tunnels. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/tweak2.png" alt="" /><figcaption>Backup Tunnels</figcaption>
</figure>
<p>{% trans -%} If that doesnt work, then the next easy thing to try is to decrease the tunnel length. Dont do this if you believe you are at risk of your code-contribution activity being de-anonymized by a well-resourced attacker seeking to run many malicious nodes and control your whole path. If that sounds unlikely to you then you can probably do it safely. {%- endtrans %}</p>
<figure>
<img src="/_static/images/git/tweak1.png" alt="" /><figcaption>One-Hop Tunnels</figcaption>
</figure>
<h2 id="trans--suggested-workflow-for-developers--endtrans">{% trans -%}<em>Suggested Workflow for Developers!</em>{%- endtrans %}</h2>
<p>{% trans -%} Revision control can make your life easier, but it works best if you use it well! In light of this, we strongly suggest a fork-first, feature-branch workflow as many are familiar with from Github. In such a workflow, the master branch is used as a sort of “Trunk” for updates and is never touched by the programmmer, instead, all changes to the master are merged from branches. In order to do set up your workspace for this, take the following steps:{%- endtrans %}</p>
<ul>
<li>{% trans -%}<strong>Never make changes to the Master Branch</strong>. You will be using the master branch to periodially obtain updates to the official source code. All changes should be made in feature branches.{%- endtrans %}</li>
</ul>
<ol type="1">
<li><p>{% trans -%}Set up a second remote in your local repository using the upstream source code.{%- endtrans %}</p>
<pre><code>git remote add upstream git@127.0.0.1:i2p-hackers/i2p.i2p</code></pre></li>
<li><p>{% trans -%}Pull in any upstream changes on your current master:{%- endtrans %}</p>
<pre><code>git pull upstream master</code></pre></li>
<li><p>{% trans -%}Before making any changes to the source code, check out a new feature branch to develop on:{%- endtrans %}</p>
<pre><code>git checkout -b feature-branch-name</code></pre></li>
<li><p>{% trans -%}When youre done with your changes, commit them and push them to your branch{%- endtrans %}</p>
<pre><code>git commit -am &quot;I added an awesome feature!&quot;
git push origin feature-branch-name</code></pre></li>
<li><p>{% trans -%}Submit a merge request. When the merge request is approved and brought into the upstream master, check out the master locally and pull in the changes:{%- endtrans %}</p>
<pre><code>git checkout master
git pull upstream master</code></pre></li>
<li><p>{% trans -%}Whenever a change to the upstream master(i2p-hackers/i2p.i2p) is made, you can update your master code using this procedure as well.{%- endtrans %}</p>
<pre><code>git checkout master
git pull upstream master</code></pre></li>
</ol>
{% endblock %}