Git serve: I would like it that simple

前端 未结 8 555
南方客
南方客 2020-12-02 03:52

I want to know how to simply publish over http = much like Mercurial\'s hg serve! On the Windows/work box do this:

git serve 

and then on t

8条回答
  •  渐次进展
    2020-12-02 04:12

    Navigate into your project and start git-daemon with the following switches:

    cd project
    git daemon --reuseaddr --base-path=. --export-all --verbose
    

    This tells git-daemon to serve up all projects inside the current directory (which I assume is the project directory containing the .git/ folder). It also tells it to re-use the same address if you shut it down and start it back up too fast.

    You can put this into a batch script with an easy to remember name like "gitserve", so you don't need to type it all out again. As suggested in some of the comments, in recent versions of Git you can add an alias to the Git config:

    [alias]
        serve = !git daemon --reuseaddr --verbose --base-path=. --export-all ./.git
    

    Once that's done on the server (your Windows box), you can do:

    git serve
    

    git-daemon uses the git:// protocol for transport, so on the client (your Linux box), you would need to do:

    git clone git://123.456.789.111/ project
    

提交回复
热议问题