Skip to content

Instantly share code, notes, and snippets.

@disouzam
Last active December 9, 2025 10:23
Show Gist options
  • Select an option

  • Save disouzam/03779f9c7163b890deb304f293b3e709 to your computer and use it in GitHub Desktop.

Select an option

Save disouzam/03779f9c7163b890deb304f293b3e709 to your computer and use it in GitHub Desktop.
Useful git configs
[gui]
encoding = utf-8
[core]
editor = \"\\Microsoft VS Code\\bin\\code\" --wait
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
excludesfile = ../.vscode/**
longpaths = true
logAllRefUpdates = true
autocrlf = true
[push]
autoSetupRemote = true
defaultremote = fork
[checkout]
defaultremote = fork
[remote]
pushDefault = fork
[alias]
all = add .
amend = commit --amend
at = tag -a
bb = "!D:/GitHubRepos/Gists/Better-git-branch/better-git-branch.sh"
bd = branch -d
bD = branch -D
ce = commit
id = log --pretty=format:%h -1
check = diff --check
check-stash = !echo 'Stash content:' && echo '' && git ssh 0 --stat &&echo '' && echo 'Staged content: ' && echo '' && git diff --cached --stat
ci = commit -m
co = checkout
cb = checkout --track
cluntd = clean --dry-run
cluntf = clean -q -f
cpa = cherry-pick --abort
cpc = cherry-pick --continue
cpex = cherry-pick -x --edit
cpn = cherry-pick --no-commit
cpnx = cherry-pick -x --no-commit
cppx = cherry-pick -x
diffA = diff --cached --diff-filter=A -w --unified=0
diffc = diff -w --unified=0
diffD = diff --cached --diff-filter=D -w --unified=0
diffM = diff --cached --diff-filter=M -w --unified=0
diffn = diff --name-status
diffwt = diff -w --unified=0
diffstaged = diff --cached -w --unified=0
fe = fetch --prune --prune-tags --verbose
fe2 = fetch --prune --verbose
fedev = fetch origin develop:develop
femain = fetch origin main:main
fl = log --format=oneline
gedit = config --global --edit
ledit = config --local --edit
lo = log --decorate --pretty=medium
lo2 = log --stat --pretty=medium
lo3 = log --stat -p --pretty=medium
lo4 = log --name-status
lo5 = log --stat --pretty=fuller
lo6 = log --oneline --reverse --pretty=format:'- %s ' --shortstat --dirstat=lines
logfile = log --pretty=medium -p
lol = log --graph --oneline --decorate
lolAll = log --graph --oneline --branches --all --decorate
lolRefs = log --graph --oneline --branches --all --decorate --reflog
lost = fsck --no-reflog
lost-commit = !git lost | grep 'dangling commit' > dangling-commits.txt
lot = log --graph --oneline --decorate --tags --simplify-by-decoration
nb = checkout -b
pl = pull
ps = push
pslease = push --force-with-lease
rltag = tag -d
rref = push origin --delete
showdetail = show --format=fuller
ssh = stash show -u
ssha = stash push --staged
sshapply = stash apply
sshdrop = stash drop
sshpop = stash pop
sshl = stash list -p --stat --pretty=medium -n 1 -s --skip
sshlist = stash list --format=oneline
sshlistd = stash list --format=medium
sshp = stash show -u -p
st = status -uall
sts = status -uall -s
stp = status -uall --porcelain=2 --branch
stage = add
stat = diff --cached --stat
summary = log --summary --pretty='1. %Cred**%h**%Creset %s%n%b'
sw = switch
swb = switch - # switch back
swc = switch -c
swd = switch --detach
tg = tag -l
tgref = show-ref --tags -s -d
track = push --set-upstream origin
unstage = reset HEAD --
up = !git co && git fe && git pl
[fetch]
prune = true
[log]
abbrevCommit = true
[format]
pretty = 1. %Cred**%h**%Creset %s
[stash]
showIncludeUntracked = true
showPatch = false
showStat = true
[rerere]
enabled = true
[column]
ui = auto
[branch]
sort = -committerdate
[maintenance]
auto = false
strategy = incremental
[merge]
conflictstyle = diff3
[init]
defaultBranch = main
# https://stackoverflow.com/questions/68724866/cannot-install-with-npm-package-from-git/72906559#72906559
[url "https://github.com/"]
insteadOf = ssh://[email protected]/
@disouzam
Copy link
Author

List of useful git configs I use at work

@disouzam
Copy link
Author

disouzam commented Oct 8, 2023

Added another useful git alias:

track = push --set-upstream origin

@disouzam
Copy link
Author

Set auto setup of local branch:

git config --global push.autoSetupRemote true

@disouzam
Copy link
Author

Diff of the last change:

diff --git a/Useful-git-configs.txt b/Useful-git-configs.txt
index ca260b2..7972738 100644
--- a/Useful-git-configs.txt
+++ b/Useful-git-configs.txt
@@ -6 +5,0 @@
-	check = diff --check
@@ -8 +7 @@
-	co = checkout
+    co = checkout main
@@ -10,2 +8,0 @@
-    cluntd = clean --dry-run
-    cluntf = clean -q -f
@@ -14,2 +11 @@
-    cpr = cherry-pick -x --edit
-    deltag = push --tags --delete
+    cpr = cherry-pick -x
@@ -35,2 +31 @@
-	sshl = stash list -p --stat --pretty=medium -n 1 -s --skip
-    sshp = stash show -u -p
+    sshl = stash list -p -n 1 -s --skip

@disouzam
Copy link
Author

Added e-mail configuration for GitHub repos

@disouzam
Copy link
Author

Aliases were updated in last revision (Revision # 15)

@disouzam
Copy link
Author

disouzam commented Aug 5, 2025

Updated alias rrtag to rref - it can be used to remove references other than tags.

Usage:

git rref tags/<tag name>

Equivalent to

git push origin --delete tags/<tag name>

@disouzam
Copy link
Author

Added lo4 as a new alias to display name status in an easy way.

A example from one of my personal repositories

1. **5a03e6b** Tutorial (#2)
1. **b1a52b2** A notebook containing all code from Real Python tutorial

A       tutorial.ipynb
1. **e534334** Excluded global Python environments from being considered in this repo

A       .vscode/settings.json
1. **cff7fee** Excluded sh, bat and ps1 extensions from being considered a repo's language

M       .gitattributes
1. **b4ce317** Setup (#1)
1. **d961c22** Basic setup of virtual environment for Python 3.12.1 with all expected packages

A       pythonSetup/activate_python3.12_environment.sh
A       pythonSetup/create_python3.12_environment.sh
A       pythonSetup/pythonPath.txt
A       pythonSetup/pythonVersion.txt
A       pythonSetup/requirements.txt
A       pythonSetup/requirements_ALL.txt
A       pythonSetup/setup.sh
A       requirements.in
1. **02dd98e** Added a gitattributes file

A       .gitattributes
1. **2f03675** Initial commit

A       .gitignore
A       LICENSE
A       README.md

@disouzam
Copy link
Author

In revision 21, fixed alignment and added another configuration to deal with multiple remote repositories

[remote]
    pushDefault = fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment