Git cli: get user info from username

后端 未结 8 2078
借酒劲吻你
借酒劲吻你 2020-12-14 05:24

Is there a way to get the name of the user, given only their username?

Something like this output git show (I know this doesn\'t work)<

相关标签:
8条回答
  • 2020-12-14 05:38

    Try this

    git config user.name
    

    git config command stores and gives all the information.

    git config -l
    

    This commands gives you all the required info that you want.

    You can change the information using

    git config --global user.name "<Your-name>"
    

    Similarly you can change many info shown to you using -l option.

    0 讨论(0)
  • 2020-12-14 05:38

    While its true that git commits don't have a specific field called "username", a git repo does have users, and the users do have names. ;) If what you want is the github username, then knittl's answer is right. But since your question asked about git cli and not github, here's how you get a git user's email address using the command line:

    To see a list of all users in a git repo using the git cli:

    git log --format="%an %ae" | sort | uniq
    

    To search for a specific user by name, e.g., "John":

    git log --format="%an %ae" | sort | uniq | grep -i john
    
    0 讨论(0)
  • 2020-12-14 05:47

    Use this to see the logged in user (the actual git account):

    git config credential.username
    

    And as other answers the user email and user name (this is differenct from user credentials):

    git config user.name
    git config user.email
    

    To see the list of all configs:

    git config --list
    
    0 讨论(0)
  • 2020-12-14 05:50

    You can try this to get infos like:

    • username: git config --get user.name
    • user email: git config --get user.email

    There's nothing like "first name" and "last name" for the user.

    Hope this will help.

    0 讨论(0)
  • 2020-12-14 05:53

    git config --list

    git config -l

    will display your username and email together, along with other info

    0 讨论(0)
  • 2020-12-14 05:54
    git config user.name
    git config user.email
    

    I believe these are the commands you are looking for.

    Here is where I found them: http://alvinalexander.com/git/git-show-change-username-email-address

    0 讨论(0)
提交回复
热议问题