
How to Create Your Own Git Server - shill
http://www.spinellis.gr/blog/20130619/
======
WestCoastJustin
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...](http://sysadmincasts.com/episodes/11-internal-git-server-with-
gitolite)

[1] [http://gitlab.org/](http://gitlab.org/)

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

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

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

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

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

* [https://rhodecode.com/](https://rhodecode.com/)

* [https://deveo.com/](https://deveo.com/)

* [https://enterprise.github.com/](https://enterprise.github.com/)

* [https://www.atlassian.com/software/stash](https://www.atlassian.com/software/stash)

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

~~~
sebastiank123
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.

------
616c
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/](http://git.zx2c4.com/cgit/)

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

[2]
[http://www.linux.com/news/software/applications/667176-cgit-...](http://www.linux.com/news/software/applications/667176-cgit-
maintainer-disappears-security-hole-found)

~~~
johnchristopher
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.

------
zrail
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...](http://www.petekeen.net/hosting-private-git-repositories-with-
gitolite)

------
actionscripted
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...](https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md)

~~~
neumann
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.

------
KevinEldon
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/](http://www.gitblit.com/)

~~~
danieldk
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 :).

------
ericedge
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-...](http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-
the-Server)

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

------
Walkman
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-...](http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server)

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

------
PetrolMan
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.

------
__david__
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.

------
Nux
Don't forget about GitBucket
[https://github.com/takezoe/gitbucket](https://github.com/takezoe/gitbucket)

------
caniszczyk
You can always use something like JGit:
[http://eclipse.org/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](http://alblue.bandlem.com/2013/11/embedding-jgit.html)

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

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

------
smoyer
Or you can just use Gitolite, Gitlab, etc

------
desireco42
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.

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

------
irremediable
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.

------
jtiseo
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/](http://gitprep.org/)

------
droptableusers
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.

------
mcormier
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...](http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-
secure-way)

------
pavanred
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?

~~~
luckydude
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.

------
aryastark
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.

