git equivalent of 'hg serve'?
Solution 1
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.
Solution 2
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
Solution 3
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/
glaucon
Updated on June 05, 2022Comments
-
glaucon about 2 years
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 over 11 yearsExcellent - 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.
-
Tuxdude over 9 years@alberthier - git-webui looks really good and installation is really straightforward as well :)
-
fbmd over 9 yearsWith git 2.1.1 on Cygwin,
git instaweb
yieldsgit: 'instaweb' is not a git command. See 'git --help'.
-
Dominik almost 8 yearsGot
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) -
Christophe Muller almost 8 yearsThanks @Dominik, I will add this tip to the answer. Without this you can pull but not push.
-
blobmaster almost 5 yearsThis should be the accepted answer as
hg serve
allow cloning.