I'd like to make my command line git client prompt for a password (as a reminder that I should think twice before pushing changes to a repo which are irreversible without admin access such as temporary branches or unsquashed/badly described commits), but I don't want to have to authenticate myself each time I want to pull (and my code base changes regularly).
At the moment I have to type in my username and password twice, once for git pull and once for git push. Can I restrict the prompting to just push?
1 Answer 1
Can I restrict the prompting to just push?
Yes: you can set your default url with your username in it, as I mention in your other question.
git remote set-url https://<yourUsername>@github.com/<yourUsername>/<yourRepo>
^^^^^^^^^^^^^^
But you also can define a push url without your username
git config remote.origin.pushURL url https://github.com/<yourUsername>/<yourRepo>
When pushing, you would have to enter your username, while pulling would only ask for the password.
If you have a credential helper , that means:
- pull will ask for the password only once per session (and keep the password in memory)
- push would ask for your username (and then the credential helper would take over)
9 Comments
git config credential.helper wincred in your repo, and give it a try: it will ask you for password only once.