3 ms·
I've used Git over SSH for several years for personal projects. It just works with no additional overhead or maintenance. Tip: create a `git` user on the serve
by imiric 1y ago
I've used Git over SSH for several years for personal projects. It just works with no additional overhead or maintenance.
Tip: create a `git` user on the server and set its shell to `git-shell`. E.g.:
sudo useradd -m -g git -d /home/git -s /usr/bin/git-shell git
You might also want to restrict its directory and command access in the sshd config for extra security.
Then, when you need to create a new repository you run:
sudo -u git git init --bare --initial-branch=main /home/git/myrepo.git
And use it like so:
git clone git@myserver:myrepo.git
Or:
git remote add myserver git@myserver:myrepo.git
git push -u myserver main
This has the exact same UX as any code forge.
I think that initializing a bare repository avoids the workarounds for pushing to a currently checked out branch.
- general1465 1y agoYes exactly, creating git user on Linux machine and configuring it just for git turned out to be easiest way how to get Source Tree and Git in Windows work with it out of the box.
- amelius 1y agoYes, that's how I use it too. However, this setup doesn't work with git-lfs (large file support). Or, at least I haven't been able to get it working. PS: Even though git-shell is very restricted you can still put shell commands in ~/git-shell-commands
- matrss 1y agoTo my knowledge git-lfs is only really designed to store your large files on a central server. I think it also uses its own out-of-band (from the perspective of git) protocol and connection to talk to that server. So it doesn't work with a standard ssh remote, and breaks git's distributed nature. For an actually distributed large file tracking system on top of git you could take a look at git-annex. It works with standard ssh remotes as long as git-annex is installed on the remote too (it provides its own git-annex-shell instead of git-shell), and has a bunch of additional awesome features.