Skip to content

Configure your environment

Configure Git

Handling configuration

How to check global configuration?

bash
git config --list --global

How to define a global configuration?

bash
git config --global {CONFIG_KEY} {CONFIG_VALUE}

Where:

  • {CONFIG_KEY} is one of the available configurations, as defined in the Git reference.
  • {CONFIG_VALUE} is the value for the configuration key.

Git Editor

You can check how to link an editor with Git in the introduction section.

Define useful aliases

Git can support custom command aliases. Those are independent of your own shell aliases and are very specific to Git.

Check aliases

Create a new alias

Just create a new alias:

bash
git config --global alias.{NAME} "{CLI_COMMAND}"

Where:

  • {NAME} will be the name of the alias command.
  • {CLI_COMMAND} is the value of the git command

For example here how you can define a simple l0 command to print last 20 commits in compact form:

bash
git config --global alias.l0 "log --oneline --clear-decorations -20"

Which you can simply use with:

bash
git l0

Some of my favorites

Checking configuration

Print all your global configuration:

bash
git showconf

List all your aliases:

bash
git alias
Daily workflow

Compact status:

bash
git st
console
## HEAD (no branch)
?? .idea/
console
interactive rebase in progress; onto 2369cf1
Last commands done (3 commands done):
   reset onto
   edit b9a34a8 implement size
  (see more in file .git/rebase-merge/done)
Next commands to do (2 remaining commands):
   pick f727659 implement dequeue
   pick d0568eb implement enqueue
  (use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'rebase1' on '2369cf1'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .idea/

nothing added to commit but untracked files present (use "git add" to track)

Show branches in colored display

bash
git br
* (no branch, rebasing rebase1) - implement size (7 days ago) [Sylvain Gamel]
  dev_experiment - implement size (7 days ago) [Sylvain Gamel]
  dev_featA - implement size (7 days ago) [Sylvain Gamel]
  rebase1 - implement enqueue (7 days ago) [Sylvain Gamel]
  main - fix bug (4 weeks ago) [Sylvain Gamel]

Changing current branch with switch command:

bash
# …to an existing branch
git sw ${BRANCH_NAME}

# …to a new branch
git sw -c ${BRANCH_NAME}

# …to previous branch
git sw -

Push to remote but force in case of amend or other rewritten history:

bash
git fpush
Checking logs

Show last history log:

bash
git last
console
commit b9a34a8072165115d23f11fdfc4becb497f3f359 (HEAD, dev_featA, dev_experiment)
Author: Sylvain Gamel <code@sylvaingamel.fr>
Date:   Sun Oct 26 22:40:36 2025 +0100

    implement size

Show history as compact display without decoration (tags and branch names):

bash
git l0 -3
console
b9a34a8 implement size
2369cf1 add test for queue size
b9bf6d1 add test for dequeue on empty queue

Show history in compact display with tags and branch names:

bash
git l1
console
b9a34a8 (HEAD, dev_featA, dev_experiment) implement size
2369cf1 (tag: stable) add test for queue size
b9bf6d1 add test for dequeue on empty queue
Using worktrees

List all worktrees in current repository:

bash
git wtl
console
/Users/sylvain/dev/lab/git-tutorials/playgrounds/rebase-int_start   b9a34a8 (detached HEAD)
/Users/sylvain/dev/lab/git-tutorials/playgrounds/rebase-int_A_wt    b9a34a8 [dev_featA]
/Users/sylvain/dev/lab/git-tutorials/playgrounds/rebase-int_exp_wt  b9a34a8 [dev_experiment]

Add a new worktrees to current repository:

bash
git wta -b ${NEW_BRANCH} ../${FOLDER_REL_PATH}
bash
git wta -b dev_experiment ../rebase-int_exp_wt
console
Preparing worktree (new branch 'dev_experiment')
HEAD is now at b9a34a8 implement size

Removing a working tree:

bash
git wtr ../${FOLDER_REL_PATH}
bash
git wtr ../rebase-int_A_wt

A short way to use worktree Git command to call other sub-commands:

bash
git wt
Configuration

Quickly define aliases above:

bash
# Configuration
git config --global alias.showconf "config --global --list"
git config --global alias.alias "config --get-regexp '^alias\.'"

# Branches
git config --global alias.st "status -sb"
git config --global alias.br "branch --format='%(HEAD) %(color:brightcyan)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative))%(color:reset) [%(color:yellow)%(authorname)%(color:reset)]' --sort=-committerdate"
git config --global alias.sw switch
git config --global alias.fpush "push --force-with-lease"

# Logs
git config --global alias.last "log -1 HEAD"
git config --global alias.l0 "log --oneline --decorate=no"
git config --global alias.l1 "log --oneline"

# Worktrees
git config --global alias.wtl "worktree list"
git config --global alias.wta "worktree add"
git config --global alias.wtr "worktree remove"
git config --global alias.wt worktree

Configure your IDE

VSCode

More information…

Visual Studio Code icon

Learn more about VSCode…
Visual Studio Code

VSCode proposes good git support, but some advanced features will either require you to jump to your terminal or install specific extensions.

My personal choice would go to GitLens, that will bring you more advanced features, such as blame annotation right in the editor or interactive rebase. A pro plan exists, but you won't need it.

More information…

Gitlens icon

Learn more about GitLens…
Gitlens

JetBrain's IntelliJ

More information…

IntelliJ IDEA

Learn more about IntelliJ…
IntelliJ IDEA

All JetBrains IDEs that I’ve tried come with excellent support for git cms. You do not need to add an external extension.