How can I allow anonymous push to a git repository over http?

前端 未结 3 1822
無奈伤痛
無奈伤痛 2021-01-01 03:20

I cannot find an example here: http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html

Is it possible?

3条回答
  •  情歌与酒
    2021-01-01 04:12

    Add this to your httpd.conf (Assuming /srv/git contains your repos)

    
        Order allow,deny
        Allow from all
    
    
    SetEnv GIT_PROJECT_ROOT /srv/git
    SetEnv GIT_HTTP_EXPORT_ALL
    ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
    

    Then make sure apache can write to your repository directory (from inside repo run this where http is your apache user)

    chown -R http .
    

    In the repository you have created on the server open up .git/config and add the following

    [http]
        receivepack = true
    

    and finally in the repository root run

    git config --bool core.bare true
    

    alternatively if you want a the files available on the server (for a web site or whatever) then disregard the above command and edit .git/config with this

    [receive]
        denyCurrentBranch = false
    

    and then run this on the server when you want to update the dir (there must be a better way so please let me know)

    git reset --hard
    

提交回复
热议问题