Hacker News new | past | comments | ask | show | jobs | submit login
How to Create Your Own Git Server (spinellis.gr)
163 points by shill on Feb 7, 2014 | hide | past | web | favorite | 35 comments



Running your own internal git server can have several advantages. Mainly, you are not sharing your code (IP) with external parties. There are many frontends you can strap onto a git server too, like Gitlab, Gitweb, Gerrit, and cgit [1, 2, 3, 4]. We use git/gitolite/gitweb heavily with our internal puppet infrastruture. You can have pre/post commit hooks for things like, syntax checking, email notification, and code deployments.

Here is the workflow:

          +--------+   +---------+
          | gitweb |   |dashboard|
  staff   +--------+   +---------+  nodes
   +-+          |           |        +-+
   +-+-\        |           |      > +-+
        \ +--+-----+     +------+-/
          |  |git  |     |puppet|
   +-+ -->|  |gito-| +-> |master| -> +-+
   +-+    |  | lite|     |      |    +-+
        / +--+-----+     +------+-
       /   |    |                 \
   +-+-    |    v                  > +-+
   +-+     |     email hook to       +-+
           |       staff if production branch
           v
            syntax hook
I created a screencast about running an internal git server with gitolite @ http://sysadmincasts.com/episodes/11-internal-git-server-wit...

[1] http://gitlab.org/

[2] https://git.wiki.kernel.org/index.php/Gitweb

[3] https://code.google.com/p/gerrit/

[4] http://git.zx2c4.com/cgit/


Just to agree - having custom post-commit hooks can really be great for your deployment infrastructure. At an old job, I had post-commit hooks setup for deploying webapps, and once I got the developers on-board, it really made our devops cleaner. We had it all backed by gitolite. (I also got them to stop coding on the live sites, but that's another story).


A very mature extremely well documented CI infrastructure built around Gerrit can be found at http://ci.openstack.org/

I'm a big fan of Gerrit though it can take a while to understand.


Thanks for mentioning GitLab. As a GitLab.com co-founder I believe it offers a much more userfriendly interface than gitweb.


Thanks for GitLab, I've been using it since v3 :)


To list some other SCM tools that support Git that you can deploy internally:

* (free) http://www.scm-manager.org/

* https://rhodecode.com/

* https://deveo.com/

* https://enterprise.github.com/

* https://www.atlassian.com/software/stash

Those last 4 cost money, but allow self hosting with more "professional" tools.


Let me correct you: RhodeCode Enterprise is free of charge for installations with up to 20 users and runs under every major platform, including Windows.


I have pretty much the same setup at my work too. It goes Gitlab->Jenkins->Puppetmaster. This works super well with Puppet dynamic environments, since each team member can have their own branch to mess around in and make mistakes. On our master branch you have to pass puppet parser validate and puppet-lint before things get to production, which helps cut down on errors.

http://puppetlabs.com/blog/git-workflow-and-puppet-environme...


We use Gerrit/Gitweb here for our 2000+ node Puppet infrastructure. It's really nimble, and (when paired with Jenkins) is pretty much set-and-forget.


Interesing that no one mentions cgit,[0] even though Linus and kernel developers moved away from the default (it comes with git itself) Gitweb Perl CGI Library a while ago.[1]

Cgit is pretty impressive stuff as a frontend. I am sure it is a mess[2] (since people here constantly gawk and harp on people bold enough to do the following), but it is merely a giant C program handling CGI with built-in caching, and it is pretty damn efficient. It is crazy fast. I used to run it on a shared host, and boy was I impressed.

Give it a look when you have a chance. You would be surprised how many large FOSS groups (if I recall correctly, I see the UI at OpenOffice, GNOME, KDE, and FreeDesktop umbrella groups).

[0] http://git.zx2c4.com/cgit/

[1] https://www.kernel.org/pelican.html

[2] http://www.linux.com/news/software/applications/667176-cgit-...


What a coincidence. I found out about cgit 30 minutes ago when looking for `pulseaudio-module-raop2`/ I was wondering about the CSS theming that gitweb instance so I looked at the source and cgit is now being compiled.


I wrote an article last year that builds this same idea with Gitolite, with bonus automatic replication to S3.

http://www.petekeen.net/hosting-private-git-repositories-wit...


If you're doing all of that, why not take it a small step further and setup your own instance of GitLab? It's a bit more work, but it's by no means difficult if you follow the install directions.

https://github.com/gitlabhq/gitlabhq/blob/master/doc/install...


or gitbucket, a single war file clone of github. I run gitlab for work, and gitbucket for personal and the latter is far easier to upgrade and maintain.


Thanks for mentioning GitLab!


Gitblit [1] is a nice option if you want an easy install (standalone app or Java WAR) and it runs fine on Windows if that is a constraint you have. It's not as feature rich as some of the other choices out there, but it is actively developed and stable.

[1] http://www.gitblit.com/


We are moving to Gitblit too (from subversion). One of the things I like about Gitblit is that much of the configuration is backed by plain-text files. While that may not be ideal if you have thousands of repositories and a gazillion users, it makes it much easier to back up or change/fix something by hand.

And indeed, the installation procedure is trivial :).


I'm unclear on why this recommends setting up a user account for every committer. I'm a big fan of simply adding each committer's ssh key to a single "git" user account to avoid the overhead of managing multiple user accounts--you have to make sure each ssh key line is identified by the user submitting it in case it needs removal in the future, but it's much easier to manage adding and removing users.

There are some additional configuration steps for that single user, but most are covered in the manual at http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-...

Is there some advantage to separate user accounts that I'm missing?


Use the "--shared" switch if users will commit the repository from the machine. For details see [1]. I think this makes step 5 unneccesary. If your ssh daemon listens on other port than 22, you can still use relative URL-s to your repo owner home directory like this [2]: ssh://user@host:port:/~/repository.git

[1]: http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-...

[2]: http://stackoverflow.com/a/14349254/720077


Just wanted to toss out another alternative in Stash by the folks at Atlassian. The setup was easy and it provides a nice interface that can hook in with Jira. Also, for small companies the 10 user license is free.


If you trust all your devs, there's also the even easier technique of just giving them accounts on the server and chgrp-ing a bare git repo so that they all have read/write access.


Don't forget about GitBucket https://github.com/takezoe/gitbucket


You can always use something like JGit: http://eclipse.org/jgit/

It's the underlying library that powers tools like Gerrit Code Review.

Many ways to embed JGit too: http://alblue.bandlem.com/2013/11/embedding-jgit.html


I'm not sure I would recommend this for 90% of the people out there and I build a product (http://gitsense.com) around it. Using Gitlab, gitolite, etc. would be much wiser choice in my opinion.


Agreed, should have prefixed it that if you wanted something more low level. Otherwise, Gitblit, Gitlab, Gerrit etc are better options.


Or you can just use Gitolite, Gitlab, etc


Without even reading this article I would say 'EASY!'. Git definitely makes it very easy to host and work with repositories. I like to use gitolite for administration, it works really well. Even before it, when git came to be, I was using ssh to host one on dreamhost, it is that easy.


I use gitolite as my own git server, pretty happy with it. Easy to configure and maintain.


Nice to see this summarised in one place. A lot of my projects are academic things that eventually end up on GitHub, but need to stay private for the first few months of their life. Hosting git on my VPS has been a godsend.


I actually just started using Gitprep and it is extremely lightweight and easy to set up. I threw it on a 128MB BuyVM account I had and it worked flawlessly. I tried Gitlab first, and while it had more features, it was far more resource intensive (since it was Rails).

http://gitprep.org/


I use GitLab on my VPS (KVM Advanced @ Edis) and I am very happy with it. However, it uses unreasonable amount of resources. I am pretty much all out of resources after deploying GitLab. I will probably switch to something else even if it has less features and worse interface as long as it use less resources.


Been doing this for quite some time. I found the following blog posts very useful when I was learning how to do this.

http://scie.nti.st/2007/11/14/hosting-git-repositories-the-e...


Am curious, I remember seeing a talk by Linus Torvalds on the internet where he explains git and how it incorporates a decentralized design to solve some inherent problems that the alternatives posed. Now, why is there emphasis on creating git servers?


My guess is that while some people love the flexibility of a distributed system (lots of different and useful workflows) the average people like centralized. SVN has more market share than Git so far as I know.

tl;dr: people like having less choices, it's less confusing.


If you just need something for yourself or a few people, you might consider an Android device. I use Gidder on a cheap tablet and it seems to work fine. Multiple users/repos. Easy to setup. It has a DynDNS option as well.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: