Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot push Git to remote repository with http/https

Tags:

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?

like image 968
Clément Avatar asked Mar 10 '11 19:03

Clément


People also ask

Does git work over HTTP?

Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git.

How do I fix git failed to push some refs?

If you get a failed to push some refs to error, the main thing to do is git pull to bring your local repo up to date with the remote.

How do I change my remote from https to SSH?

Switching remote URLs from HTTPS to SSH Change the current working directory to your local project. List your existing remotes in order to get the name of the remote you want to change. Change your remote's URL from HTTPS to SSH with the git remote set-url command. Verify that the remote URL has changed.

How to push commits to a remote repository in Git?

Pushing commits to a remote repository 1 Renaming branches. To rename a branch, you'd use the same git push command, but you would add one more argument: the name of the new branch. 2 Dealing with "non-fast-forward" errors. ... 3 Pushing tags. ... 4 Deleting a remote branch or tag. ... 5 Remotes and forks. ... 6 Further reading

How do I push to a remote url on GitHub?

That URL could be your repository on GitHub, or another user's fork, or even on a completely different server. You can only push to two types of URL addresses: Git associates a remote URL with a name, and your default remote is usually called origin. You can use the git remote add command to match a remote URL with a name.

How do I push a branch to remote in Git?

Push Branch To Remote. In order to push a Git branch to remote, you need to execute the “ git push ” command and specify the remote as well as the branch name to be pushed. $ git push <remote> <branch>. For example, if you need to push a branch named “ feature ” to the “origin” remote, you would execute the following query.

What is remote repository in GitHub?

About remote repositories A remote URL is Git's fancy way of saying "the place where your code is stored." That URL could be your repository on GitHub, or another user's fork, or even on a completely different server. You can only push to two types of URL addresses:


2 Answers

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.

like image 186
Deepak Avatar answered Oct 27 '22 00:10

Deepak


It is highly suggested NOT to use WebDAV if possible. If you must use HTTP/HTTPS then usage of the git-http-backend CGI script is recommended over WebDAV.

like image 36
Arrowmaster Avatar answered Oct 26 '22 22:10

Arrowmaster