For those who aren't aware, Git is actually a fully decentralised system. It doesn't <i>require</i> a central server as such - though most teams use one, as it's a convenient setup for most projects.<p>Even if you are hosting on github/bitbucket/et. al. though, that repository is just one of many equals. You can push and pull from multiple peers as long as you have access set up appropriately.<p>I recommend the chapter on distributed workflows in Pro Git:<p><a href="https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows" rel="nofollow">https://git-scm.com/book/en/v2/Distributed-Git-Distributed-W...</a><p>There's also an explanation of the different supported protocols here:<p><a href="https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols" rel="nofollow">https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protoco...</a>
Gitlab also can be run in your own server. It actually has an enterprise and an open source version. We use the open source one for a couple of years and it is really great - I recommend it with all my heart.<p>It has great instructions for installing directly from source and you don't really need to be familiar with ruby to install it. It requires some standard components (web server, database) which should exist on all servers and then you follow the instructions and presto! You have your own gitlab!! It also has great upgrade instructions so you can always be up-to-date.<p>I know gitlab can also be used through the cloud version (and it even has free private repos) however some organizations feel better if the source code of their projects stay inside the organization.
This is a good setup if you are the only one accessing the repo.<p>If you need something a little bit more complex, I would highly recommend gitolite for managing repositories & users. Configuration is done via some INI/TOML-like files in a git repo. User public keys are stored in the same repo.
I've been using Gogs happily for two years:<p><a href="https://gogs.io/docs/installation" rel="nofollow">https://gogs.io/docs/installation</a>
Assuming you already have files in your home directory on the server backed up, and SSH access, then a repository for a single user is as simple as<p><pre><code> mkdir project.git; cd project.git
git init --bare
</code></pre>
And to clone<p><pre><code> git clone user@example.com:project.git</code></pre>
"Doing this is cheaper than paying GitHub, and it will give you the satisfaction of being a True Hacker."<p>Or I could work on problems that really matter and leave the sysadmin job to someone who gets paid to do it. ;)<p>More seriously, when I was in college, I spent a lot of time doing things like running my own mailserver, selfhosting various projects, etc. I learned a lot. But in the Real World, I don't want to be responsible for more than I have to be; off the shelf products are just better for me, most of the time.<p>The fact that Bitbucket and Github will pay a guy to run a git server for me is amazing (even if it is evidence of some sort of irrational enthusiasm on part of VC firms). Why would I not want to take advantage?
Why do this when <a href="http://bitbucket.com" rel="nofollow">http://bitbucket.com</a> will host private git repos for free? They also have have Large File Storage implemented as well.<p>I use GitHib client using BitBucket for repo hosting with LFS and it works great, no need to host anything.
If you don't need code review and don't mind a hosted solution, you can get by with the AWS free tier and use IAM for all your access control.<p><pre><code> AWS CodeCommit:
5 active users per month
50 GB-month of storage per month
10,000 Git requests per month
Does not expire at the end of your 12 month AWS Free Tier term.
</code></pre>
<a href="https://aws.amazon.com/s/dm/optimization/server-side-test/free-tier/free_np/" rel="nofollow">https://aws.amazon.com/s/dm/optimization/server-side-test/fr...</a>
Very interesting benchmark of gitbucket vs gitea vs gitlab on a raspberry pi ;)<p><a href="https://gitbucket.github.io/gitbucket-news/gitbucket/2017/03/29/benchmark-of-gitbucket.html" rel="nofollow">https://gitbucket.github.io/gitbucket-news/gitbucket/2017/03...</a>
Security question. Can `git-shell` restrict users to their remote home directory? Or if you give me a git shell, can I still do things like `git clone me@example.com:/home/you/secret-sauce` ?<p>This is only an issue if you're sharing the box and/or remote repositories with other people. For shared remote repositories I've been using the following setup:<p>1. Create a bare, shared repository at `/var/git/foo`. Configure unix group permissions and the directory setuid bit on it.<p>2. Give alice access via a `/home/alice/foo -> /var/git/foo` symlink.<p>3. Set alice's shell to a patched version of the git shell I call `git-home-shell` that sanitizes the repository path argument and makes it relative to her home dir.<p>Is there a better way these days?
Quick note: what this article doesn't explicitly says is that as long as you have a shell account somewhere with a decent amount of disk space, you can host or mirror all the repository you want.<p>If I may make a suggestion, I'd recommend the Super Dimensional Fortress Public Access UNIX System (<a href="https://sdf.org/" rel="nofollow">https://sdf.org/</a>).<p>They're NetBSD-based if I remember correctly, and for a low fee (36$/lifetime ARPA membership + 9$/quarter) you can host most of the things you would like to host.<p>And you don't have to do system maintenance.
Why self-host your repo but store backups without encryption at google or amazon? If you want it to be private, just make it so.<p>edit: thanks anyway for your version!
I do self-host a few repositories as well, but I do not set up a separate user: I just create a git/ dir in the home dir of the account I want to host the repositories on and put the repositories there.<p>To simplify the initial setup, I created a handy shell script, reposetup [1]. It makes to create repositories, push to them and remind me their urls.<p>[1]: <a href="https://github.com/agateau/reposetup" rel="nofollow">https://github.com/agateau/reposetup</a>
If you’re using Google Cloud, you can already use Google Cloud Source Repositories. <a href="https://cloud.google.com/source-repositories/" rel="nofollow">https://cloud.google.com/source-repositories/</a> It supports git and the Beta release of Cloud Source Repositories provides free hosting of up to 1GB of storage.
As others have already stated, this article is a great introduction for when you'll be the only one to access the repositories, as anyone able to authenticate for that account will have access to all repos.<p>There are some tools that restrict access with varying levels of granularity, but if you just want to restrict access on a per-repo-per-sshkey basis, one of my projects is a simple shell script that does just that:<p><a href="https://github.com/cbdevnet/fugit" rel="nofollow">https://github.com/cbdevnet/fugit</a><p>It originally came to be because I've found gitolite too big to maintain for simply sharing some repositories with a few other people. It has since served me well and is used in some business applications, too.
Does anyone know of a good AMI or Docker container that's got all this already set up, as far as it's possible?<p>(I know it doesn't look complicated, but if there's a decent "standard" already out there...)
<a href="http://gitblit.com/" rel="nofollow">http://gitblit.com/</a> is also worth looking into. It is more sophisticated then gitolite (which I also use) and less hairy then gitlab. It is Java based, but doesn't require a database.<p>Also, for backup, rather then tar up the ".git" directory, I use "git bundle <backupfilename> --all" which creates a flat file with all branches included. This file can then be uploaded to GCS or S3.
If you want something light weight and "run and done" then check out GitBucket [0]. You only need the JVM & git installed. When you run the program it sets everything up. Very easy, clean interface, and simple to back up (I just snapshot the entier folder).<p>[0] - <a href="https://github.com/gitbucket/gitbucket" rel="nofollow">https://github.com/gitbucket/gitbucket</a>
Just do it in google drive or dropbox, get backups for free.<p><a href="https://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively/1961515#1961515" rel="nofollow">https://stackoverflow.com/questions/1960799/using-git-and-dr...</a>
Has anyone had any experience in getting Passbolt (<a href="https://github.com/passbolt" rel="nofollow">https://github.com/passbolt</a>) working for authentication with Git?
I do this often. One thing, if you want to have multiple users all working on the same repo, which I believe is a common use case, you have to take group permissions and umask into account. Works really nice.
What this article doesn't cover are how to set up the things that make Github so useful like issue tracking and pull requests. Github (and similar services like bitbucket) are more than just Git.