Search code examples
gitgit-push

Prompt for password but not username?


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.


Solution

  • 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.