问题
Is it possible to get git to prompt only for a password, and determine your username automatically? I want to have the extra layer of manual intervention as a reminder to be careful what I push, but just entering a password and not also the username every time is sufficient.
回答1:
If you are using https url, you can change said url in order to include your username just before the git repos hosting server (here, for instance, github.com
):
git remote set-url origin https://<yourUsername>@github.com/<yourUsername>/<yourRepo>
^^^^^^^^^^^^^^
Each time you will git push
, it will ask only for your password.
来源:https://stackoverflow.com/questions/33424582/prompt-for-password-but-not-username