2022/04/14
Loosely based on official docs.
This obviously assumes you’re an admin of some OpenBSD system. With
minor adjustments this will work on other UNIX-like systems, probably
only doas
(sudo without bloat) is the only OpenBSD specific
thing.
doas pkg_add git
doas useradd -m -c "git repo" -s /usr/local/bin/git-shell git
Add developers’ public SSH keys to git’s
authorized_keys
:
doas -u git "sh" "-c" 'echo no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty YOUR_PUBLIC_KEY >> /home/git/.ssh/authorized_keys'
If authorized_keys
wasn’t created automatically before
(via /etc/skel
), make it yourself:
doas -u git "mkdir" "/home/git/.ssh"
doas -u git "mkdir" "-p" "/home/git/repos/YOUR_REPO_NAME"
doas -u git "git" "init" "--bare" "/home/git/repos/YOUR_REPO_NAME"
On your workstation cd to the directory with your project. There:
git init
git add .
git config user.name "Your name"
git config user.email "Your email"
git commit -m "Initial import"
git remote add origin git@FQDN_OF_YOUR_SERVER:/home/git/repos/YOUR_REPO_NAME
git push origin master
You should see something like:
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 656 bytes | 656.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To FQDN_OF_YOUR_SERVER:/home/git/repos/YOUR_REPO_NAME
* [new branch] master -> master
Your git server is ready.