If I set display_user:true inside my oh-my-posh theme json file (spaceship.omp.json), I can see my windows account name. I want to know If I can do the same for git username.
Asked
Active
Viewed 169 times
0
-
2There's a flaw of sorts in the question: you're not *logged in* to Git, ever. You do "log in" to GitHub briefly when using `git push`, but only for the duration of that one `git push`. Git itself has no authentication of any kind and merely reads the configured data at `git commit` time (and completely trusts it, regardless of what it says). However, GPG signing (and the upcoming ssh signing) are not as naïve, but here again you don't really *log in*, you just have access to various secrets (not under Git's control in any way). – torek Jul 28 '21 at 01:55
-
For (much) more about how *GitHub* does authentication, see my [long answer here](https://stackoverflow.com/a/68491559/1256452). – torek Jul 28 '21 at 01:56
-
Thanks for that really appreciate it. – user14831698 Jul 28 '21 at 06:00
1 Answers
3
Git will use the config for user.name
and user.email
when creating commits. You can retrieve see their current values with:
git config user.name
git config user.email
Note that those configs can be just defined in your personal .gitconfig
file (the usual) or they can be defined in a global system .gitconfig
or redefined in a project .gitconfig
, so you can have different values for different repositories.
Also note that these config values are what git will use to commit or sign your work, but not necessarily which github account will be used. That'll be determined by how the remote has been configured, as the remote server will typically identify you by your SSH keys, in which case git will use any key installed usually in ~/.ssh
that you have added to your github account.

Pepe Doval
- 84
- 5