TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to Host Your Own Private Git Repositories

271 pointsby eklitzkeabout 8 years ago

28 comments

peterkellyabout 8 years ago
For those who aren&#x27;t aware, Git is actually a fully decentralised system. It doesn&#x27;t <i>require</i> a central server as such - though most teams use one, as it&#x27;s a convenient setup for most projects.<p>Even if you are hosting on github&#x2F;bitbucket&#x2F;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:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;en&#x2F;v2&#x2F;Distributed-Git-Distributed-Workflows" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;en&#x2F;v2&#x2F;Distributed-Git-Distributed-W...</a><p>There&#x27;s also an explanation of the different supported protocols here:<p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;en&#x2F;v2&#x2F;Git-on-the-Server-The-Protocols" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;en&#x2F;v2&#x2F;Git-on-the-Server-The-Protoco...</a>
评论 #14137261 未加载
评论 #14148670 未加载
spapas82about 8 years ago
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&#x27;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.
评论 #14135808 未加载
uiriabout 8 years ago
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 &amp; users. Configuration is done via some INI&#x2F;TOML-like files in a git repo. User public keys are stored in the same repo.
评论 #14134431 未加载
评论 #14134673 未加载
评论 #14134586 未加载
评论 #14134814 未加载
评论 #14134587 未加载
falavaabout 8 years ago
I&#x27;ve been using Gogs happily for two years:<p><a href="https:&#x2F;&#x2F;gogs.io&#x2F;docs&#x2F;installation" rel="nofollow">https:&#x2F;&#x2F;gogs.io&#x2F;docs&#x2F;installation</a>
评论 #14133655 未加载
评论 #14134607 未加载
Symbioteabout 8 years ago
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>
md_about 8 years ago
&quot;Doing this is cheaper than paying GitHub, and it will give you the satisfaction of being a True Hacker.&quot;<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&#x27;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?
评论 #14136935 未加载
评论 #14137121 未加载
midnitewarriorabout 8 years ago
Why do this when <a href="http:&#x2F;&#x2F;bitbucket.com" rel="nofollow">http:&#x2F;&#x2F;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.
评论 #14134102 未加载
评论 #14134684 未加载
评论 #14133958 未加载
评论 #14134692 未加载
评论 #14133865 未加载
评论 #14136318 未加载
评论 #14134246 未加载
philsnowabout 8 years ago
If you don&#x27;t need code review and don&#x27;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:&#x2F;&#x2F;aws.amazon.com&#x2F;s&#x2F;dm&#x2F;optimization&#x2F;server-side-test&#x2F;free-tier&#x2F;free_np&#x2F;" rel="nofollow">https:&#x2F;&#x2F;aws.amazon.com&#x2F;s&#x2F;dm&#x2F;optimization&#x2F;server-side-test&#x2F;fr...</a>
sandGorgonabout 8 years ago
Very interesting benchmark of gitbucket vs gitea vs gitlab on a raspberry pi ;)<p><a href="https:&#x2F;&#x2F;gitbucket.github.io&#x2F;gitbucket-news&#x2F;gitbucket&#x2F;2017&#x2F;03&#x2F;29&#x2F;benchmark-of-gitbucket.html" rel="nofollow">https:&#x2F;&#x2F;gitbucket.github.io&#x2F;gitbucket-news&#x2F;gitbucket&#x2F;2017&#x2F;03...</a>
sigilabout 8 years ago
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:&#x2F;home&#x2F;you&#x2F;secret-sauce` ?<p>This is only an issue if you&#x27;re sharing the box and&#x2F;or remote repositories with other people. For shared remote repositories I&#x27;ve been using the following setup:<p>1. Create a bare, shared repository at `&#x2F;var&#x2F;git&#x2F;foo`. Configure unix group permissions and the directory setuid bit on it.<p>2. Give alice access via a `&#x2F;home&#x2F;alice&#x2F;foo -&gt; &#x2F;var&#x2F;git&#x2F;foo` symlink.<p>3. Set alice&#x27;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?
评论 #14135212 未加载
评论 #14136932 未加载
znpyabout 8 years ago
Quick note: what this article doesn&#x27;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&#x27;d recommend the Super Dimensional Fortress Public Access UNIX System (<a href="https:&#x2F;&#x2F;sdf.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sdf.org&#x2F;</a>).<p>They&#x27;re NetBSD-based if I remember correctly, and for a low fee (36$&#x2F;lifetime ARPA membership + 9$&#x2F;quarter) you can host most of the things you would like to host.<p>And you don&#x27;t have to do system maintenance.
评论 #14134889 未加载
exceptioneabout 8 years ago
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!
评论 #14134429 未加载
agateauabout 8 years ago
I do self-host a few repositories as well, but I do not set up a separate user: I just create a git&#x2F; 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:&#x2F;&#x2F;github.com&#x2F;agateau&#x2F;reposetup" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;agateau&#x2F;reposetup</a>
alpbabout 8 years ago
If you’re using Google Cloud, you can already use Google Cloud Source Repositories. <a href="https:&#x2F;&#x2F;cloud.google.com&#x2F;source-repositories&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cloud.google.com&#x2F;source-repositories&#x2F;</a> It supports git and the Beta release of Cloud Source Repositories provides free hosting of up to 1GB of storage.
评论 #14147668 未加载
_cbdevabout 8 years ago
As others have already stated, this article is a great introduction for when you&#x27;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:&#x2F;&#x2F;github.com&#x2F;cbdevnet&#x2F;fugit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cbdevnet&#x2F;fugit</a><p>It originally came to be because I&#x27;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.
RangerScienceabout 8 years ago
Does anyone know of a good AMI or Docker container that&#x27;s got all this already set up, as far as it&#x27;s possible?<p>(I know it doesn&#x27;t look complicated, but if there&#x27;s a decent &quot;standard&quot; already out there...)
评论 #14134656 未加载
评论 #14134974 未加载
评论 #14134952 未加载
jisabout 8 years ago
<a href="http:&#x2F;&#x2F;gitblit.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;gitblit.com&#x2F;</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&#x27;t require a database.<p>Also, for backup, rather then tar up the &quot;.git&quot; directory, I use &quot;git bundle &lt;backupfilename&gt; --all&quot; which creates a flat file with all branches included. This file can then be uploaded to GCS or S3.
gravypodabout 8 years ago
If you want something light weight and &quot;run and done&quot; then check out GitBucket [0]. You only need the JVM &amp; 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:&#x2F;&#x2F;github.com&#x2F;gitbucket&#x2F;gitbucket" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gitbucket&#x2F;gitbucket</a>
tlarkworthyabout 8 years ago
Just do it in google drive or dropbox, get backups for free.<p><a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;1960799&#x2F;using-git-and-dropbox-together-effectively&#x2F;1961515#1961515" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;1960799&#x2F;using-git-and-dr...</a>
RAWRfftfftfftabout 8 years ago
Has anyone had any experience in getting Passbolt (<a href="https:&#x2F;&#x2F;github.com&#x2F;passbolt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;passbolt</a>) working for authentication with Git?
reza_nabout 8 years ago
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.
aruncabout 8 years ago
Kallithea is good enough for this use case. We are using it in a 15 member team, without any issue.
yeukhonabout 8 years ago
Anyone use AWS&#x27;s CodeCommit as a mirror for your GitHub repository?
dreamcompilerabout 8 years ago
What this article doesn&#x27;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.
lighttowerabout 8 years ago
pip install git-remote-dropbox<p>Is a git extension to allow a Dropbox to be used as your remote. Works from the CLI. Been using it for two years.
newsat13about 8 years ago
Mmm. Just use GitLab&#x2F;Gogs on cloudron?
mwfoglemanabout 8 years ago
I use Gogs and a self-hosted sandstorm.io.
评论 #14173330 未加载
marcinkuzminskiabout 8 years ago
RhodeCode is a good option for hosting, it has an advanced permission system, streaming push support and it scales well.
评论 #14134853 未加载