Skip to content

Instantly share code, notes, and snippets.

@aeswibon
Last active June 25, 2025 15:03
Show Gist options
  • Select an option

  • Save aeswibon/41df2e3f53121fa7c6afe20ce8cad053 to your computer and use it in GitHub Desktop.

Select an option

Save aeswibon/41df2e3f53121fa7c6afe20ce8cad053 to your computer and use it in GitHub Desktop.
[user]
email = contact.abhiuday@gmail.com
name = Abhiuday
signingkey = <key>
[credential "https://github.com"]
helper =
helper = !gh.exe auth git-credential
[credential "https://gitlab.com"]
helper = !glab.exe auth gitlab-credential
[credential "https://gist.github.com"]
helper =
helper = !gh.exe auth git-credential
[commit]
gpgsign = true
[alias]
head-branch = symbolic-ref --short HEAD # e.g. master.
set-base = "!git config --local --add remote.\"$1\".gh-resolved base #"
unset-base = "!git config --local --unset remote.\"$1\".gh-resolved #"
up-remote-branch = "!git rev-parse --abbrev-ref --symbolic-full-name @{u}" # e.g. origin/master.
up-remote = "!git rev-parse --abbrev-ref --symbolic-full-name @{u} | cut -d '/' -f 1" # e.g. origin.
up-branch = "!git rev-parse --abbrev-ref --symbolic-full-name @{u} | cut -d '/' -f 2-" # e.g. master.
push-branch = "!git rev-parse --abbrev-ref --symbolic-full-name @{push}" # What would be pushed to, pushRemote/$(git head-branch) if set, else @{u}.
remote-org = "!git remote get-url $1 | awk -F ':|/' '{if ($NF) {print $(NF-1)} else {print $(NF-2)}}' #" # Github org for remote. `g remote-org up` -> gibfahn.
remote-repo = "!git remote get-url $1 | sed -e 's|.*/||' -e 's/.git$//' #" # Github repo for remote. `g remote-repo up` -> dot.
pr-message = "!printf \"$(git show --format='%s' -s)\"$'\\n\\n---\\n#### Commits _(oldest to newest)_\\n\\n'\"$(git lpr)\" #" # Generates a default PR message.
ca = commit --amend
cm = commit -s -m
ce = commit -s
cf = commit -s -f
co = checkout
dn = diff HEAD --name-only # diff of staged and unstaged file names.
dp = diff @{push} # diff between working tree and upstream branch.
dpn = diff --name-only @{push} # diff between working tree and upstream branch file names.
dps = diff --staged @{push} # diff between working tree and upstream branch.
ds = diff --staged # Diff of staged files (`git diff` for unstaged).
dt = difftool # Nicer way to view diffs in vim.
du = diff @{u} # diff between working tree and upstream branch.
dun = diff --name-only @{u} # diff between working tree and upstream branch file names.
dus = diff --staged @{u} # diff between working tree and upstream branch.
# `l` gives you history of current branch, `la` is all commits in repo, `las` is a shortlist of the important commits, `ll` shows you who and when.
l = log --graph --decorate --oneline # Graph log.
la = log --graph --decorate --oneline --all # Graph log of all commits.
las = log --graph --decorate --oneline --all --simplify-by-decoration # Graph log of tag/branch/labelled commits.
ll = log --color --graph --pretty=format:'%C(214)%h%C(reset)%C(196)%d%C(reset) %s %C(35)(%cr)%C(27) <%an>%C(reset)'
# Interactive log of $@.
li = "!git log --graph --color=always --format=\"%C(auto)%h%d %s %C(black)%C(bold)<%an> %cr%C(auto)\" \"$@\" \
| fzf --ansi -m --no-sort --reverse --tiebreak=index \
--preview \"git show --color=always \\$(grep -oE '[a-f0-9]{7,}' <<< {} | head -1) | delta \" \
--d \"ctrl-o:execute: git shi \\$(grep -oE '[a-f0-9]{7,}' <<< {} | head -1)\" \
| grep -oE '[a-f0-9]{7,}' #"
lia = li --all
# Escape < and > for github markdown, (useful for generating changelogs).
lpr = "log -s --reverse --format='%h %s%n%n%b%n<br/>%n' @{upstream}..@" # Log to paste into a PR comment.
changelog = "! git log --pretty=format:'* %h - %s %n%w(76,4,4)%b%n' --abbrev-commit \"$@\" | perl -0 -p -e 's/(^|[^\\\\])([<>])/\\1\\\\\\2/g ; s/(\\s*\\n)+\\*/\\n\\n*/g' #"
# TODO(gib): remove opr and clean up once https://github.com/cli/cli/issues/1645 is resolved.
opr = "!set -x; hub pull-request --base $(git remote-org ${1:-$(git up-remote)}):${2:-$(git up-branch)} -oc -e -m \"$(git pr-message)\" #" # Raise PR against upstream remote/branch (or $1/$2).
pr = "!set -x; GH_REPO=$(git remote get-url $(git up-remote)) gh pr create --base $(git up-branch) --body \"$(git pr-message | vipe)\"#" # Raise PR against upstream remote/branch (or $1/$2).
;pr = "!set -x; gh pr create --base $(git up-branch) --title \"$(git show --format='%s' -s | vipe)\" --body \"$(git pr-message | vipe)\" #" # Raise PR against upstream remote/branch (or $1/$2).
;pr = "!set -x; remote-branch=${1:-$(git up-remote-branch)}; remote=${remote-branch%/*} branch=${remote-branch##*/} ; gh pr create --repo $(git remote get-url $remote) --base $branch --title \"$(git show --format='%s' -s | vipe)\" --body \"$(git pr-message | vipe)\" #"
pu = push --set-upstream # Set current branch as upstream branch
ra = remote add # Add new remote by url.
rb = rebase -S # Rebase and gpg sign.
rba = rebase --abort # Bail on the rebase session.
rbc = rebase --continue # Accept the current commit.
rbs = rebase --skip # Skip current commit you're rebasing on.
rhu = reset --hard @{u} # Reset hard to the upstream commit.
rhp = reset --hard @{push} # Reset hard to the push commit.
rh = reset --hard # Reset hard (to HEAD by default).
rr = remote rename # Change name of remote `g rr origin up`.
rre = remote remove # Remove any remotes
rs = remote set-url # Change URL of remote `g rs up hsg:dot`.
rsp = remote set-url --push # Change push URL of remote (`g rs up hhg:dot && g rsp up hsg:dot` to use https for fetch and ssh for push, which is faster).
rv = remote -v # Show remotes (with URLs).
s = "!git status && git push-status #" # Status including diff from @{push}.
ss = status --short --branch
# git wa </new/path/> <branch_to_checkout>; <do work in /new/path>; git wr </new/path>
wa = worktree add
wr = worktree remove
bh = "!git for-each-ref --format '%(refname:short)' refs/heads"
# z is fuzzy log (fuzzy search through `git log $*`, za is the same with la (try g sh `g z`).
z = "!git l --color=always $* | grep -v '^\\.\\.\\.\\s\\+$' | fzf +s -m --ansi | sed 's/^\\W\\+\\(\\w\\+\\)\\s\\+.*/\\1/' #"
za = "!git la --color=always $* | grep -v '^\\.\\.\\.\\s\\+$' | fzf +s -m --ansi | sed 's/^\\W\\+\\(\\w\\+\\)\\s\\+.*/\\1/' #"
[apply]
whitespace = fix # Fix whitespace when applying patches.
# Color options: normal, black, red, green, yellow, blue, magenta, cyan, or white (or 0-255).
# Highlight options: bold, dim, ul (underline), blink, and reverse (swap fg and bg).
# Diff colours aren't needed as using delta as a pager.
; # Change the colours for `git branch`.
[color "branch"]
current = cyan bold # The branch you're currently on.
local = yellow bold # Other normal branches.
remote = green bold # Local-tracking branches for your remotes.
upstream = red bold # No idea what this is (make it orange to find out).
plain = normal ul # No idea what this is (underline it to find out).
# Change colours for `git status`.
[color "status"]
localBranch = blue dim # Only used in status --short.
remoteBranch = magenta dim # Only used in status --short.
nobranch = red dim # IDK when this is used.
header = white bold # Standard git waffle.
branch = blue dim # Current branch.
added = green bold # Files added to index (ready to commit).
changed = cyan bold # Files not added, but tracked by git.
untracked = yellow bold # Files git knows nothing about.
unmerged = red bold # Files that have conflicts in git rebase.
[format]
pretty = fuller # Shows author and committer.
[help]
autocorrect = 1 # Autocorrect nonexistant commands after 0.1s
[pull]
rebase = true # pull = fetch + rebase, not fetch + merge.
[gpg]
program = /opt/homebrew/bin/gpg
[safe]
directory = *
[core]
editor = nvim
autocrlf = false
eol = lf
sshCommand = ssh -i ~/.ssh/id_github
[merge]
tool = nvim
[mergetool]
keepBackup = false
prompt = false
[mergetool "vimdiff"]
cmd = "nvim -d $MERGED $LOCAL $BASE $REMOTE -c 'wincmd J | wincmd ='"
[http]
postBuffer = 52428800
[difftool "sourcetree"]
cmd = "'' "
[mergetool "sourcetree"]
cmd = "'' "
trustExitCode = true
[init]
defaultBranch = master
[credential "helperselector"]
selected = manager
[credential]
helper = cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment