Configure your environment
Configure Git
Handling configuration
How to check global configuration?
git config --list --globalHow to define a global configuration?
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:
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:
git config --global alias.l0 "log --oneline --clear-decorations -20"Which you can simply use with:
git l0Some of my favorites
Checking configuration
Print all your global configuration:
git showconfList all your aliases:
git aliasDaily workflow
Compact status:
git st## HEAD (no branch)
?? .idea/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
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:
# …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:
git fpushChecking logs
Show last history log:
git lastcommit b9a34a8072165115d23f11fdfc4becb497f3f359 (HEAD, dev_featA, dev_experiment)
Author: Sylvain Gamel <code@sylvaingamel.fr>
Date: Sun Oct 26 22:40:36 2025 +0100
implement sizeShow history as compact display without decoration (tags and branch names):
git l0 -3b9a34a8 implement size
2369cf1 add test for queue size
b9bf6d1 add test for dequeue on empty queueShow history in compact display with tags and branch names:
git l1b9a34a8 (HEAD, dev_featA, dev_experiment) implement size
2369cf1 (tag: stable) add test for queue size
b9bf6d1 add test for dequeue on empty queueUsing worktrees
List all worktrees in current repository:
git wtl/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:
git wta -b ${NEW_BRANCH} ../${FOLDER_REL_PATH}git wta -b dev_experiment ../rebase-int_exp_wtPreparing worktree (new branch 'dev_experiment')
HEAD is now at b9a34a8 implement sizeRemoving a working tree:
git wtr ../${FOLDER_REL_PATH}git wtr ../rebase-int_A_wtA short way to use worktree Git command to call other sub-commands:
git wtConfiguration
Quickly define aliases above:
# 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 worktreeConfigure your IDE
VSCode
More information…
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…
Learn more about GitLens…
Gitlens
JetBrain's IntelliJ
More information…
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.