Reputation: 1682
I worked alone on a project versioned on Github, so for convenience I put something like this in my ~/.git/config file:
url = https://[email protected]/COMPANY/PROJECT.git
This way git asks only for password on pull/push. But now more people have to push and pull, so we thought this would make git ask also for user name:
url = https://github.com/COMPANY/PROJECT.git
But instead git asks for nothing now and this is a sample result of git pull:
error: The requested URL returned error: 403 while accessing https://github.com/COMPANY/PROJECT.git/info/refs
fatal: HTTP request failed
How can git be forced to ask for user name and password as expected?
Upvotes: 7
Views: 7096
Reputation: 1682
I work on some different servers now and I've noticed that this issue affects git 1.7.0.4, but not the newer 1.7.9.5. So anyone experiencing the same problem should upgrade their git if possible.
@jszakmeister suggested asking the git mailing list, but having read this stackoverflow thread and this github page I think there's no point, it looks like a known problem without a good known solution. Github say they recommend git 1.7.10 and people in the stackoverflow discussion suggest things that don't really solve my problem. So I guess the only option is updating your git - let consider that the solution and this question answered.
Upvotes: 4
Reputation: 47022
Are you using a credential helper? What does git config --get credential.helper
show? If it shows something, then perhaps the information is being cached by the credential helper. One way of removing it would be:
printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT.git\nusername=MYUSERNAME\n\n" |
git credential fill
It it prompts you for the password, then it's not cached in that particular form. It could be that it was cached without the .git
on the end:
printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT\nusername=MYUSERNAME\n\n" |
git credential fill
You can remove the credential with:
printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT.git\nusername=MYUSERNAME\n\n" |
git credential remove
or, if no '.git' was present on the url:
printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT\nusername=MYUSERNAME\n\n" |
git credential remove
Note that the only difference between these two commands and the above commands is that git credential fill
became git credential remove
. Also, if you post any data that comes from the git credential fill
command, make sure to obscure your username and password.
If none of that helps, you may need to look at your ~/.gitconfig
. You may have some credential.<url>
blocks set up as outlined in this man page. Alternatively, you might be able to use that to alter the username.
Upvotes: 0