With popularity of Github and many other competing offerings, it’s easy to overlook how simple it is to set up (unlimited) private repos on any network connected computer.
For example, I run this blog on a cheap instance of Linode, where $5 a month get’s you 20Gb SSD storage.
But you don’t have to pay anything. During my start up days back in 2012 we had an old gaming box connected to internet, that served as our “unlimited” private git server.
All is needed to set it up is:
On git server
ssh demo@demoserver.com # Would be your username and server url here cd /home/demo/ # Some location accessible by all users with ssh access mkdir demo.git # Create new repo cd demo.git git init --bare # Initialize git
On client (any computer that will be pulling/pushing code)
git clone ssh://demo@demoserver.com:/home/demo/demo.git cd demo/ git status -s
Note that it’s just like regular scp
command. With ssh://
being protocol, demo
username, demoserver.com
site’s URL, and home/demo/demo.git
location of the git repo.
First commit
vim README.md git add . git commit -m 'First commit' git push
Now the private repo has the README.md
file committed.
Testing the repo
cd ~/Desktop/ mkdir deleteme cd deleteme/ git clone ssh://demo@ademoserver.com:/home/demo/demo.git cd demo git log
You should see the First commit
in log.
Final thoughts
This approach will not provide “Pull Request” management or issue tracking. If those features are desired, I would recommend looking into an open-source self-hosted solutions like Gitlab.
That being said, as someone who likes to use the command line and hack away on small projects (keeping some of them private), I find the outlined approach to be sufficient for 80% of my use cases.
If you don’t want to give shell access, or if you want to control access to the repository in easier way than UNIX file permissions on repository give, then I recommend the Gitolite tool (mainly about SSH access via public-key authentication, but it also supports HTTPS access).
With Gitolite you don’t need to create empty repository on server “by hand”; with appropriate configuration (which is done via pusing to special gitolite-admin repository) you can simply use “push to create”.