Skip to content

Instantly share code, notes, and snippets.

@itsmunim
Created April 3, 2020 07:02
Show Gist options
  • Select an option

  • Save itsmunim/dab993fb303d504c1343dc7f052fccd6 to your computer and use it in GitHub Desktop.

Select an option

Save itsmunim/dab993fb303d504c1343dc7f052fccd6 to your computer and use it in GitHub Desktop.
.gitconfig with necessary aliases
[alias]
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View the current working tree status using the short format
st = status
br = branch
co = checkout
# Rebases with a remote branch- git rebase-with upstream remote-branch
rebase-with = !git pull --rebase ${1} ${2}
# Add all and commit
cm = !"git add -A && git commit -m"
# Save work as a temp commit tracked and untracked both
save = !git add -A && git commit -m 'SAVEPOINT'
# Save work as temp commit only tracked changes
wip = !git add -u && git commit -m "WIP"
# Resets last commit, keeps its changes
undo = reset HEAD~1 --mixed
# Create a commit and then reset hard, you can always come back to that commit
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
# List aliases
aliases = config --get-regexp alias
# Amend the currently staged files to the latest commit
amend = commit --amend --reuse-message=HEAD
# Delete merged
cleanup = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# List contributors with number of commits
contributors = shortlog --summary --numbered
# Detect whitespace errors when applying a patch
whitespace = fix
[core]
# Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
# Treat spaces before tabs and all kinds of trailing whitespace as an error
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# Make `git rebase` safer on macOS
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
trustctime = false
# Prevent showing files whose names contain non-ASCII symbols as unversioned.
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = false
# Speed up commands involving untracked files such as `git status`.
# https://git-scm.com/docs/git-update-index#_untracked_cache
untrackedCache = true
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal. (This is the default setting in Git ≥ 1.8.4.)
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = yellow
changed = green
untracked = cyan
#[commit]
# https://help.github.com/articles/signing-commits-using-gpg/
# gpgsign = true
[diff]
# Detect copies as well as renames
renames = copies
[diff "bin"]
# Use `hexdump` to diff binary files
textconv = hexdump -v -C
[help]
# Automatically correct and execute mistyped commands
autocorrect = 1
#[merge]
# Include summaries of merged commits in newly created merge commit messages
#log = true
[push]
# https://git-scm.com/docs/git-config#git-config-pushdefault
default = simple
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true
# URL shorthands
[url "[email protected]:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "[email protected]:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[user]
name = <your name>
email = <your mail>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment