A (very) basic git server and repository can be handy for a couple of reasons. I personally use it for Puppet code and some scripting.
To install git, just run a basic apt install git
and you are good to go. No configuration needed.
/srv/git
and make sure your git users will be able to write into it. There are basically two approaches to accomplish that, one is to create a 'git' user who will receive the public SSH key of all your users and will be used by all of them and the other is to create a 'git' group that will grant write access to that directory. Preferably you should use ACL's for that to make sure local changes or umasks cannot get into your way, but that is of course completely up to you.mkdir -p /srv/git/puppet.git
cd /srv/git/puppet.git; git init
vi .git/description
git config --global user.name "Your Name" git config --global user.email you@example.com git config --global credential.helper store git config --global push.default simple git config --global color.ui true
touch README.md; git add .; git commit -m "Initialize Repository"
Now you are good to go to use this repo from a remote computer that has SSH access to this system.
apt install git
git clone ssh://user@server.tld/srv/git/puppet.git
cd puppet
git pull
git checkout -b mybranch
git add .
git commit -m "My meaningful change description"
git push -u origin mybranch
cd /srv/git/puppet.git
git branch
git merge mybranch
git branch -D mybranch
git checkout master
git branch -D mybranch
git pull; git fetch --prune
git status
to check that, or just use my ZSH configuration which will show the current branch.git push -u origin mybranch --delete
git fetch origin master git reset --hard FETCH_HEAD git clean -df
Actually, stuff like parsing & linting, merging on the server and deploying your code where it belongs (e.g. Puppet) should be automated. A basic git setup like this doesn't allow for this, unless you throw some serious scripting at it. If you want pipelines and e.g. Jenkins, you need tools like GitHub.
Unfortunately, they do not offer an open-source version of their software that can be self-hosted, just hosted by them or in an Enterprise Edition. Luckily, there is GitLab that provides all of this functionality. And: it will run on Debian So if you want or need pipelines and user/privilege management etc, you should check out GitLab.