Picture of Christian Screen
Christian Screen

How to show or change your Git username or email address from terminal

Twitter
LinkedIn

As a basic refresher for most working on multiple coding projects or git-scm hosted accounts changing from one git account to another begs the question:

How do I see or change my Git (or github) username (usually email address)?

How to show your Git username – the basics

Use one of these methods:

  1. git config -get [user.name | user.email]
  2. git config –list
  3. or, open your git config file directly

Let’s examine each of these show your git username basics:

#1 – Use the command, git config -get [user.name | user.email]

git config user.name

This returns

Christian Screen

And if you enter git config user.email from the terminal from anywhere with your git initiated directory such as

git config user.email

this will return

cscreen@aiteamsuperstars.com

#2 – Use the command, ‘git config –list’

This approach shows all of the key configurations from your git config file, so entering the command from the terminal:

git config --list

will return the following:

credential.helper=osxkeychain
user.name=Christian Screen
user.email=cscreen@aiteamsuperstars.com

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/aicglabs/datalakehouse.git

#3 – Use the ‘open your git config file directly’ approach via the terminal

If the above approaches for some reason did not work then open the file for reading/editing in your terminal window or favorite editor. Terminal window review and editing is recommended to avoid issues. Use the following command to view the global git settings:

vi ~/.gitconfig

This will open the VimEditor and your .gitconfig file should look something like this:

[user]
        name = Christian Screen
        email = cscreen@aiteamsuperstars.com

Since this is your ‘global’ git user information (using the user home director path, ~/) you could have a different settings in other projects you might be working on.

NB: I find it best that if you have a specific project you are contributing to and need to use different credentials for the contribution, you should clone the project and then within the project use the command line to change your user.name and user.email just for that local git repository clone project to not impact your global settings. This would look like this from the command line (notice the –global is missing):

git config user.name "Christian Contribution Project"
git config user.email "christian@personalemail.com"

Read below if you’d like to see how to change your global Git username or email address.

How to change your Git username – the basics

Changing your Git username is fairly straightforward. In your terminal window enter the following:

git config --global user.name "Christian The Architect"

You can then view the change directly in the ~/.gitconfig file or just use the ~/.gitconfig file to edit the user.name key/value pair directly in the Vim Editor as you see here:

vi ~/.gitconfig

Since this is again your global Git config file, be sure edit it carefully. Remember in the Vi(m) Editor, use the ‘Esc’ key and then type ‘wq’ and then press the ‘Return’ or ‘Enter’ key to write/save the file and exit.

How to change your Git email address – the basics

You can change your email address with the same process and command as you would your username using these commands from the terminal:

git config --global user.email "cscreen@aiteamsuperstars.com"

View any of your global changes (those made with the –global flag) using either command below:

cat ~/.gitconfig
vi ~/.gitconfig

Hopefully you’ll have success remembering these basic Git commands.

More to explorer

AI ChatGPT

Building a Generative AI Competency (or the First Gen AI Project)

When Building a Generative AI Competency one must identify the necessary infrastructure, architecture, platform, and other resources and partners that can help an AI initiative be successful. We have just like many data warehouse and digital transformation initiatives over the last 20 years fail because of poor leadership, or companies only going half in on the objective.

Scroll to Top