After googling “hosting a git server”, I chose linuxfoundation's blog post as a guide, but as per my usual skepticism, ignored such headscratching suggestions as `git remote add origin ssh://git@remote-server/repo-<wbr< a="">>path-on-server.git`
(sic) (what does that even mean?) and simplified the instructions. In the following steps, I will show my server name as `githost`, easily set using an entry in /еtc/hosts or ~/.ssh/config, and my own username as `me`.
First, as root on githost:
apt install git-core
adduser git
usermod -L git
cp -r ~me/.ssh ~git/
chown -R git:git ~git/
rm ~git/.ssh/id_rsa*
Then, logging out of the server, back on my own machine:
ssh git@githost
mkdir -p jcomeauictx/lzw
cd jcomeauictx/lzw
git init --bare
Logging out again, back in my own /usr/src/jcomeauictx/lzw repository:
git remote add githost git@githost:jcomeauictx/lzw
git push githost master
Done. Now I can push to github.com and to my own githost with the same syntax and directory structure. I can’t, of course, safely have other users on my server with this barebones method, but since none of my projects have active contributors besides me as yet, this is good enough for now.
[Note: this has been edited from the original. I had earlier said `git add remote…` instead of `git remote add…`; substack had changed `git init --bare` to `git init —bare` and I didn’t know how to fix it (now learned that you just type some extra hyphens until you get separate hyphens, then erase the emdash; or alternatively type hyphen-space-hyphen then backspace over the space); and finally, substack kept giving me “network errors” (actually 403 “Forbidden” errors as shown in the Javascript console) which turned out to be due to typing slash etc slash hosts, for which I found a workaround of pasting in the Cyrillic “ye” character, which looks the same as Latin “e”).]