Prompt for password but not username?

冷暖自知 提交于 2019-12-07 19:07:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!