05 August 2012

Github HTTPS Read and Write Push URL Broken

It's good to use Git's own protocol to push and pull repositories, but sometimes that's blocked by your company's IT department.  In that case, you may use the HTTPS protocol

To pull, copy the HTTP URL from the Github project page.  It should be in the form of https://github.com/theUserName/theProjectName.git.

Then in your terminal, do a git clone https://github.com/theUserName/theProjectName.git to get the project repository.

After making and committing some changes, you may wish to push the changes to Github again.  Of course, you should do something like git pull origin theDesiredBranchName to ensure you've gotten the latest changes from Github first.  Then you'd do a git push origin theDesiredBranchName.

If it works properly, it should prompt you for your Github username and password.  Or it doesn't work, you run into a problem, and git gives you this error:

error: The requested URL returned error: 403 while accessing https://github.com/theUserName/theProjectName.git/info/refs

fatal: HTTP request failed


Solution? No guarantees, but this worked for me.  In terminal, do:

git remote set-url origin https://YourUserName@github.com/theUserName/Booking.git

Obviously, change "YourUserName" to your Github username.

Then again do git push origin theDesiredBranchName. If it works properly, it should prompt you for only your Github password.

For some reason Github denies HTTPS access sometimes if the username isn't sent along with the project URL.

No comments: