Trying to push through cgit

304 views Asked by At

I'm aware that you can not push through cgit since it's a frontend to see your git repos. But it can act as a dumb endpoint, allowing to clone for example: git clone http://192.168.1.124/cgit/myProject.git/, once you've done it you'll end up with this remote origin result:

$ git remote show origin
* remote origin
  Fetch URL: http://192.168.1.124/cgit/myProject.git/
  Push  URL: http://192.168.1.124/cgit/myProject.git/
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)

The problem is when you want to push your changes you have to change the url
from: http://192.168.1.124/cgit/myProject.git/
to: http://192.168.1.124/git/myProject.git/.

I've tried changing the configuration of my cgitrc and the configuration from the apache2 trying to redirect the query using regex but without results.

Do you have any configuration that fix this?

Thank you in advance.

1

There are 1 answers

0
Raúl Martín On BEST ANSWER

I've found this apache configuration that works for me. Check for the query and then replace the url.

ScriptAlias /cgit/ "/usr/lib/cgit/cgit.cgi/"                                                                                                                   
                                                                                                                                                               
Alias /cgit-css "/usr/share/cgit/"                                                                                                                             
                                                                                                                                                               
<Directory "/usr/lib/cgit/">                                                                                                                                   
        RewriteEngine On                                                                                                                                       
        AllowOverride None                                                                                                                                     
        Options ExecCGI FollowSymlinks                                                                                                                         
        Require all granted                                                                                                                                    
        RewriteCond %{QUERY_STRING} ^service=git-(receive|upload)-pack$                                                                                          
        RedirectMatch "/cgit/(.*)/info/refs" "/git/$1/info/refs"                                                                                               
</Directory>