Saturday, 7 September 2013

How to make Git only ask password when push to remote repository

How to make Git only ask password when push to remote repository

The requirement is probably odd. But sometimes I really need this
functionality. Ok, here is the thing, I'm always working behind proxies.
Either at office I'm using corp proxy or at home I'm using VPN and proxy
as well (You know, I'm in China, so I hope you can understand).
Usually I'm using git protocol to connect github remote repository, but
it's hard for me to set proxy behind git protocol, so I decided to switch
back to http(s) with following command
git remote set-url https://github.com/<username>/repo.git
git config http.proxy http://proxy:8080
And it works like a charm. But git asks for username and password whenever
I connect to the remote server, for example pull/push.
I only have one github account and I want to save some typing, so the
question is how to avoid typing github username everytime I want to push.
I could accept to type my password, but I don't want to type username. How
to achieve that?

No comments:

Post a Comment