-
-
Save wickdninja/5c4382d38bc2924b2abb09bb6e345711 to your computer and use it in GitHub Desktop.
My git config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = TODO | |
email = TODO | |
[filter "lfs"] | |
clean = git-lfs clean -- %f | |
smudge = git-lfs smudge -- %f | |
process = git-lfs filter-process | |
required = true | |
[push] | |
autoSetupRemote = true | |
[rebase] | |
autosquash = true | |
[init] | |
defaultBranch = main | |
[alias] | |
last = log -1 HEAD | |
unstage = reset HEAD -- | |
pop = "!f() { git reset --soft HEAD@{${1:-1}}; }; f" | |
drop = "!f() { git reset --hard HEAD@{${1:-1}}; }; f" | |
rb = for-each-ref --sort=\"-authordate:iso8601\" --format=\" %(authordate:relative)%09%(refname:short)\" refs/heads | |
st = status | |
clean-branches = !git branch | grep -ve \" master$\\|dev$\\|main$\" | xargs git branch -D | |
update-branches = !git branch | tr -d '*' | grep -e \" master$\\|dev$\\|main$\" | xargs git pull origin | |
# Get the current branch name (not so useful in itself, but used in | |
# other aliases) | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# Push the current branch to the remote "origin", and set it to track | |
# the upstream branch | |
publish = "!git push -u origin $(git branch-name)" | |
publish-force = "!git push --force --set-upstream origin $(git branch-name)" | |
# Delete the remote version of the current branch | |
unpublish = "!git push origin :$(git branch-name)" | |
# Delete a branch and recreate it from master — useful if you have, say, | |
# a development branch and a master branch and they could conceivably go | |
# out of sync | |
recreate = "!f() { [[ -n $@ ]] && git checkout \"$@\" && git unpublish && git checkout master && git branch -D \"$@\" && git checkout -b \"$@\" && git publish; }; f" | |
# Fire up your difftool (e.g. Kaleidescope) with all the changes that | |
# are on the current branch. | |
code-review-master = difftool origin/master... | |
code-review-main = difftool origin/main... | |
# Given a merge commit, find the span of commits that exist(ed) on that | |
# branch. Again, not so useful in itself, but used by other aliases. | |
merge-span = "!f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f" | |
# Find the commits that were introduced by a merge | |
merge-log = "!git log `git merge-span .. $1`" | |
# Show the changes that were introduced by a merge | |
merge-diff = "!git diff `git merge-span ... $1`" | |
# As above, but in your difftool | |
merge-difftool = "!git difftool `git merge-span ... $1`" | |
# Interactively rebase all the commits on the current branch | |
rebase-branch-main = "!git rebase -i `git merge-base main HEAD`" | |
rebase-branch-master = "!git rebase -i `git merge-base master HEAD`" | |
# | |
# Working with files | |
# | |
# Unstage any files that have been added to the staging area | |
unstage = reset HEAD | |
# Show changes that have been staged | |
diffc = diff --cached | |
# Mark a file as "assume unchanged", which means that Git will treat it | |
# as though there are no changes to it even if there are. Useful for | |
# temporary changes to tracked files | |
assume = update-index --assume-unchanged | |
# Reverse the above | |
unassume = update-index --no-assume-unchanged | |
# Show the files that are currently assume-unchanged | |
assumed = "!git ls-files -v | grep ^h | cut -c 3-" | |
# delete tag whos name is the first arg | |
delete-tag = "!f() { \ | |
echo 'deleting tag' $1 'from remote/origin ausing command: git push --delete origin tagName;'; \ | |
git push --delete origin $1; \ | |
echo 'deleting tag' $1 'from local using command: git tag -d tagName;'; \ | |
git tag -d $1; \ | |
}; f" | |
# commit with branch name as message prefix | |
bc = "!f() { bname=\"$(git symbolic-ref --short HEAD) \"; read -i \"$bname\" -e && [[ ${#bname} -lt ${#REPLY} ]] && git commit -m \"$REPLY\" || echo aborted; }; f; unset f bname" | |
# commit | |
c = "!f() { git commit -m \"$@\";}; f" | |
# find branch with name | |
find = "!f() { branch=${1}; query=${2}; git log $branch --grep=$query; }; f" | |
# list tags | |
tags = log -n1 --pretty=format:%h%d | |
# git fixup with no verify step | |
fixup = "!f() { parentCommit=${1}; git commit --no-verify --fixup $parentCommit; }; f" | |
# commit currently staged changes with wip message | |
wip = "!f() { git commit --no-verify -m \"WIP: $@\"; }; f" | |
# like git fixup but with less steps | |
fix = commit --amend --no-edit | |
# like git fixup but with less steps and no verify step | |
fu = "!git a && git commit --amend --no-edit --no-verify" | |
# short hand functions for ease of use | |
fp = push --force | |
pf = push --force | |
pub = publish | |
pubf = pub --force | |
unpub = unpublish | |
unpubf = unpub --force | |
s = status | |
a = add -A | |
cp = cherry-pick | |
fap = fetch --all --prune | |
ct = describe --tags | |
main = checkout main | |
master = checkout master | |
# fuzzy checkout | |
co = "!f() { git branch -a | grep -m1 -e ${1}.*${2} | sed \"s/remotes\\/origin\\///\" | xargs git checkout; }; f" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment