Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent git pull asking for username password from github when remote repository not found

I've looked at all the questions about configuring username / password for 'git pull', but none address the issue when the remote repository is 404.

I've git clone'd a repository from github sometime in the past. For whatever reason, the repository owner has deleted the repo, and git pull fails. Before it fails though, git pull asks for username and password.

This happens because I have a directory of cloned github git repos, and I'm trying to update them all by shell script that goes into each directory and does a 'git pull'.

$ git pull
ksshaskpass: cannot connect to X server 
error: unable to read askpass response from '/usr/lib/ssh/ssh-askpass'
Username for 'https://github.com': 
ksshaskpass: cannot connect to X server 
error: unable to read askpass response from '/usr/lib/ssh/ssh-askpass'
Password for 'https://github.com': 
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/[ ... ]
like image 289
codeDr Avatar asked Oct 15 '25 13:10

codeDr


1 Answers

I've found myself in a similar situation, and my solution was to set a fake credential provider for Git by doing:

export GIT_ASKPASS="/bin/true"

This causes the pull / clone to fail immediately rather than prompting for a username and password. It's a bit of a hack, but I couldn't find any other simple way of preventing the prompt.

like image 106
Chris Avatar answered Oct 18 '25 09:10

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!