Check GitHub Account in the Terminal

GitHub is an integral tool for developers to store, manage, and collaborate on software projects with other developers. And as we work more and more in the command line it is important as a developer to know the commands to interact with the connected GitHub account right from the terminal.

In this article, we will see some handy commands to check the github account in the terminal. These commands will allow us to check GitHub authentication status, username, email address, remote connections, and overall account configuration through the command line interface.

Check GitHub Authentication Status

The GitHub CLI tool gh can be used to check if you are currently authenticated to GitHub via the terminal session:

gh auth status

It will print out the authentication status in the terminal and show whether the user is logged in or not logged in. And if you are logged in, it will display your github username and the authentication method used.

If you get the error “‘gh’ is not recognized as an internal or external command,
operable program or batch file.” in Windows then you have to install the github CLI in your system.

For windows you can download the executable file from Download GitHub CLI, or you can install it using wget by using the command:

winget install --id GitHub.cli	

The installation instruction for all major operating system can be found in there officail page: Link GitHub to the command line

Check GitHub Username

The git config command allows you to view the username and email configured locally for connecting with your GitHub account. You can check it using the following command:

git config user.name

This will display the GitHub account username stored in your local git configuration ie. the account with which you are currently logged in.

Check GitHub email ID

Similar to the username you can also check your GitHub email address by typing the following command in your terminal:

git config user.email

It will display the email address of the Github account you are locally logged-in in the terminal.

View all GitHub Config Settings in the Terminal

If you want to view all the configuration of your GitHub account, then you have to use the -l flag:

git config -l

This will print out your GitHub username, user email id as well as any other custom GitHub settings you may have configured.

View all GitHub settings in your terminal

Check Remotes Connected to GitHub

If you want to check which of your git repositories are connected to GitHub accounts. We can use git remote command to list out remote URLs:

git remote -v

It will print out all the URLs of the repositories that are connected to your GitHub username. This helps you to check if your git remotes connect to Github or another service this way.

Conclusion

Learning GitHub account commands like gh auth status, git config, and git remote makes inspecting account details much easier directly through the terminal. Whether you need to check your login status, username, email, or remote connections, these commands have got you covered!

You can download the github Cheatsheet that contains more commonly used github commands here: GitHub Cheatsheet


FAQ

How to check Github account in terminal?

You can check github’s logged-in account username and email id using git config user.name and git config user.email command.

How to find Github username?

To get your github username type git config user.name in your terminal. It will displayed to logged-in github account username.

How to check git username and email in terminal

You can check git username and email in terminal using git config user.name and git config user.email command.

Scroll to Top