51

Is there some sort of addon you can use to have a git equivalent of the Mercurial

hg serve

('hg serve' starts a local web-server which allows you to browse the repository history/branches etc)

glaucon
  • 8,112
  • 9
  • 41
  • 63
  • This appears to be a duplicate of http://stackoverflow.com/questions/438163/whats-the-best-web-interface-for-git-repositories – Youn Elan Mar 27 '13 at 22:26
  • 2
    @YounElan: I think this is a separate question. The question you link to is about setting up a GitHub clone locally whereas this question is about starting a short-term web server so that others can push/pull from you. – Martin Geisler Mar 28 '13 at 08:53

3 Answers3

68

For just browsing files and revisions git instaweb is the right solution.

In addition if you want to set-up an ad-hoc git server for sharing work (push/pull) with some colleagues (which hg serve also allows you to do), you can use:

git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack

Your colleagues will use it with something like:

git clone git://<ip-address>/.git project

Addition 1:

If you want to be able to push to this server, you need to add the --enable=receive-pack option (Thanks to Dominik below).

Addition 2:

It just happened to me so I add it to the answer :-), if you are using a Redhat-based Linux distribution (RHEL, CentOS, etc.) and have an error "git: 'daemon' is not a git command.", then you need to install a seperate package for it:

sudo yum install git-daemon
aaaidan
  • 7,093
  • 8
  • 66
  • 102
Christophe Muller
  • 4,850
  • 1
  • 23
  • 31
  • 1
    Got `fatal: remote error: access denied or repository not exported: REPO` using the Git server. On server side: `'receive-pack': service not enabled for DIR/REPO`. The solution is to add `--enable=receive-pack` (see @itsadok's [answer](http://stackoverflow.com/a/792621/1168315)) – Dominik Aug 15 '16 at 11:32
  • Thanks @Dominik, I will add this tip to the answer. Without this you can pull but not push. – Christophe Muller Aug 18 '16 at 13:32
  • This should be the accepted answer as `hg serve` allow cloning. – blobmaster Sep 09 '19 at 09:43
25

I think what you're looking for is git instaweb.

By default it uses lighttpd, but any other web server like webrick also should work.

I prefer webrick because it is much convenient (and I have ruby and webrick gem installed)

Examples:

# Starts a web server on port 1234 and opens up a web browser
git instaweb --httpd=webrick

# To stop webrick
git instaweb --httpd=webrick --stop

You should be able to configure the instaweb settings in your .git/config or ~/.gitconfig and merely run git instaweb --start and git instaweb --stop to control instaweb:

[instaweb]
    local = true
    httpd = webrick
    port = 1234
    browser = chromium

UPDATE:

git-webui which alberthier mentioned in his answer, is actually a much richer UI compared to the default instaweb and installation is also really straight-forward.

Community
  • 1
  • 1
Tuxdude
  • 47,485
  • 15
  • 109
  • 110
  • Excellent - thanks very much. I did use lightttpd instead of webrick and because I wanted to view the results outside the machine I was working on I set 'local = false'. Worked fine. – glaucon Mar 28 '13 at 03:05
  • With git 2.1.1 on Cygwin, `git instaweb` yields `git: 'instaweb' is not a git command. See 'git --help'.` – fbmd Jan 07 '15 at 08:59
9

git-webui is a git extension which provides a web based user interface and the ability to clone/pull from other computers

https://github.com/alberthier/git-webui

$ cd my_git_repo
$ git webui

Other people can

$ git clone http://<ip-of-your-computer>:8000/ repoclone

or

$ git pull http://<ip-of-your-computer>:8000/
alberthier
  • 643
  • 1
  • 7
  • 9
  • @alberthier - git-webui looks really good and installation is really straightforward as well :) – Tuxdude Oct 08 '14 at 06:11