Git protocol: Difference between revisions

From wikinotes
(Created page with "The simplest way of serving git, unauthenticated and read-only. {{ WARNING | Make sure to add the (empty) file git-daemon-export-ok to every repository that you want to allow...")
 
No edit summary
Line 6: Line 6:
}}
}}


= Creaate Repo =
= Documentation =
<blockquote>
<blockquote>
<source lang="bash">
{| class="wikitable"
sudo systemctl enable git-daemon
|-
sudo systemctl start  git-daemon
| <code>man git-daemon</code> || https://man.archlinux.org/man/extra/git/git-daemon.1.en
|-
|}
</blockquote><!-- Documentation -->


mkdir /srv/git
= Configuration =
</source>
<blockquote>
 
== Enable GitDaemon ==
<source lang="bash">
<blockquote>
FreeBSD
<syntaxhighlight lang="bash">
echo "git_daemon_enable=\"YES\"" >> /etc/rc.conf
echo "git_daemon_enable=\"YES\"" >> /etc/rc.conf
service git_daemon start
service git_daemon start


mkdir /usr/local/git
mkdir /usr/local/git
# even though the daemon runs as git_daemon, the dir should be owned by git
chown git:git /usr/local/git
chown git:git /usr/local/git
</source>
</syntaxhighlight>


Copy your project to the remote location.
Archlinux
<source lang="bash">
<syntaxhighlight lang="bash">
cp -Ra /home/git/<project>   /usr/local/git
sudo systemctl enable git-daemon
sudo systemctl start  git-daemon
mkdir /srv/git
</syntaxhighlight>
</blockquote><!-- Enable GitDaemon -->


# git daemon only exposes projects with this file
== Add Repo ==
touch /usr/local/git/<project>/git-daemon-export-ok
<blockquote>
</source>
Copy/Link repo to git-daemon's configured dir,<br>
and add <code>git-daemon-export-ok</code> to mark it allowed for export.
<syntaxhighlight lang="bash">
ln -s /repos/${repo} /usr/local/git/${repo}
touch /usr/local/git/${repo}/git-daemon-export-ok
</syntaxhighlight>
</blockquote><!-- Add Repo -->


<source lang="bash">
== Pull From Repo ==
# daemon is started with following options: /usr/lib/git-core/git-daemon --inetd --export-all --base-path=/srv/git
<blockquote>
#
<syntaxhighlight lang="bash">
# (repositories in /srv/git/ (linux) /usr/local/git (freebsd)  will be able to be cloned)
git clone git://${your_server}:9418/usr/local/git/repository.git
 
</syntaxhighlight>
git clone git://gitbox:9418/usr/local/git/repository.git
</blockquote><!-- Pull From Repo -->
</source>
</blockquote><!-- Configuration -->
</blockquote><!-- Creaate Repo -->

Revision as of 15:45, 31 July 2022

The simplest way of serving git, unauthenticated and read-only.


WARNING:

Make sure to add the (empty) file git-daemon-export-ok to every repository that you want to allow git-daemon to access. Otherwise access denied.

Documentation

man git-daemon https://man.archlinux.org/man/extra/git/git-daemon.1.en

Configuration

Enable GitDaemon

FreeBSD

echo "git_daemon_enable=\"YES\"" >> /etc/rc.conf
service git_daemon start

mkdir /usr/local/git
chown git:git /usr/local/git

Archlinux

sudo systemctl enable git-daemon
sudo systemctl start  git-daemon
mkdir /srv/git

Add Repo

Copy/Link repo to git-daemon's configured dir,
and add git-daemon-export-ok to mark it allowed for export.

ln -s /repos/${repo} /usr/local/git/${repo}
touch /usr/local/git/${repo}/git-daemon-export-ok

Pull From Repo

git clone git://${your_server}:9418/usr/local/git/repository.git