Cannot push Git to remote repository with http/https

后端 未结 8 2090
借酒劲吻你
借酒劲吻你 2020-11-27 15:44

I have a Git repository in a directory served by apache on a server. I have configured WebDAV and it seems to be running correctly. Litmus returns 100% success.

I ca

8条回答
  •  遥遥无期
    2020-11-27 16:22

    En example of write authentified git dav virtualhost with gitweb enable that could solve your problem :

    
            ServerAdmin admin@example.com
            ServerName git.example.com
    
            DocumentRoot /var/git
    
            # SSL configuration
            SSLEngine on
    
            # Fix dav header
            #RequestHeader edit Destination ^https: http: early
    
            
                    DAV on
                    Options ExecCgi FollowSymLinks
    
                    # Gitweb config
                    AddHandler cgi-script .cgi
                    DirectoryIndex .gitweb.cgi
                    SetEnv GITWEB_CONFIG /var/git/.gitweb.conf
    
                    # Basic auth config
                    AuthType Basic
    
                    # Auth title
                    AuthName "Git repositories"
    
                    # Use file and external providers
                    AuthBasicProvider file
    
                    # File location
                    AuthUserFile /var/git/.htpasswd
    
                    Require method GET OPTIONS PROPFIND
                    
                            Require valid-user
                    
            
    
    

    Then just clone your repository with your user :

    git clone https://user@git.example.com/repository
    

    And when you will try to push it will ask your password and provide it.

    Placing the password in the clone url is a security bad practice as anyone can read it in your .git/config.

提交回复
热议问题