Cannot push Git to remote repository with http/https

Clément picture Clément · Mar 10, 2011 · Viewed 66.4k times · Source

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 can clone my repository from a remote host, but when trying to push over http or https, I get the following error:

error: Cannot access URL https://git.example.com/repo/, return code 22 fatal: git-http-push failed

Any idea?

Answer

Deepak picture Deepak · Mar 12, 2013

Edit the following section of your .git/config file:

[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://git.repository.url/repo.git

to

[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://username:[email protected]/repo.git

Then try git push origin master.

Edit the authentication details in your config files for other repository URLs as required and push to the required branch.