2

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?

asked Oct 29, 2015 at 21:02

1 Answer 1

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)
answered Oct 30, 2015 at 5:12
Sign up to request clarification or add additional context in comments.

9 Comments

Thanks, I didn't know you could set separate URLs for pushing and tracking.
@Sridhar-Sarnobat didn't you accept this answer before?
Hmmmm, so this doesn't actually make the pull touchless unless you use credential helper does it?
I'm having a bit of trouble understanding how to use the credential helper.
@Sridhar-Sarnobat are you on Windows? If yes, type git config credential.helper wincred in your repo, and give it a try: it will ask you for password only once.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.