简体   繁体   中英

git equivalent of 'hg serve'?

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)

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

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM