Git commands

git config

git config: configure your Git settings.

git config is a command used to set configuration options for your Git installation, affecting how Git behaves and looks for you. These settings can be related to your identity (name and email), the styling of command output, the default editor for writing commit messages, and much more. These configurations help in personalizing the Git setup to suit your workflow.

Configuration levels in Git include:

  • Local: Configuration settings for the specific repository you are working in.
  • Global: Configuration settings for your user account on your computer, affecting all repositories you work with.

Using git config, you can manage these settings across different levels, allowing for fine-grained control of Git's behavior. For example, setting your email address at the global level means every commit across all projects on your computer will include that email address as the author.

When you first set up Git, it's a good idea to configure your global settings, which will apply to all repositories you work with on your machine. You can also override these global settings on a per-repository basis if needed.

Examples

Get your global user name configuration:

git config --global user.name

Set your user name and email address globally:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Set the default branch name for new repositories:

git config --global init.defaultBranch "main"

Set your preferred text editor (e.g., VSCode) globally:

git config --global core.editor "code --wait"

List all global configuration settings:

git config --global --list

Set a repository-specific user email address. We omit the --global option to set this configuration only in the current repository:

git config user.email "work.email@example.com"
© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

And this is Gitopedia—a reference that summarizes knowledge in my Git course.

Gitopedia is designed to be a personal knowledge base. When you progress through the main Git course in VS Code, you unlock all of these topics, one by one, bit by bit. This gives you time to digest the information and gradually build the mental model of Git. Here's an example of how it works:

Learning directly in VS Code lets you practice Git exactly as you would in real life, doing real jobs, writing real code. In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code