Skip to content

Instantly share code, notes, and snippets.

@hyoretsu
Created July 21, 2025 17:36
Show Gist options
  • Select an option

  • Save hyoretsu/01f0024d892ba79ff07c65e933103252 to your computer and use it in GitHub Desktop.

Select an option

Save hyoretsu/01f0024d892ba79ff07c65e933103252 to your computer and use it in GitHub Desktop.
Git Stuff
[advice]
addEmptyPathspec = false
[alias]
bc = "!f() { git checkout $1 2>/dev/null || git checkout -b $1 origin/$1 2>/dev/null || git checkout -b $1; }; f"
bcr = "!f() { git branch -D $1 || true && git checkout -b $1; }; f"
bd = branch -D
bump = !git checkout main && git rebase dev && git ps && git checkout dev
cfg = config --global --edit
cln = !git reset . && git restore . & git clean -qfd
cm = "!f() { git add . && git commit -m \"$1\"; }; f"
cmn = "!f() { git add . && git commit --no-verify -m \"$1\"; }; f"
cmt = "!f() { git commit -m \"$1\"; }; f"
cn = "!f() { git commit --no-verify -m \"$1\"; }; f"
cp = cherry-pick
cpa = cherry-pick --abort
cpc = !git add . && git cherry-pick --continue
create = !mkdir $2 && cd $2 && git init && gh repo create $2 --public -y
drop = stash drop
fix = !git add . && git reset .
fork = checkout -b
lg = log --abbrev-commit --format='%Cred%h%Creset %Cgreen%ah%Creset %C(bold blue)<%an>%Creset %s%d'
list = stash list
migrate = !git branch -m master main && git branch --set-upstream-to=origin/main
pl = pull
plr = pull --rebase
pop = !git stash pop $1 && git add . && git reset .
ps = push
psf = push --force
psn = push --no-verify
psnf = push --force --no-verify
r = revert
ra = revert --abort
rb = rebase -i --committer-date-is-author-date
rba = rebase --abort
rbc = !git add . && git rebase --continue
rbfc = update-ref -d HEAD
rc = revert --continue
rs = reset
st = status -s
sta = stash apply\"
std = "!f() { email=$(git config --get user.email); git for-each-ref --format=\"%(refname)\" \"refs/stashes/$email/*_$(git rev-parse --short stash@{${1:-0}})\" || true & git stash drop ${1:-0}; }; f"
ste = "!f() { email=$(git config --get user.email); git stup; old_refs=$(git for-each-ref --format=\"%(refname)\" \"refs/stashes/$email\"); echo \"$old_refs\" | xargs -r git push origin --delete; echo \"$old_refs\" | xargs -r
-n 1 git update-ref -d; refspecs=\"\"; for i in $(seq $(expr $(git rev-list --walk-reflogs --count stash 2>/dev/null || echo 0) - 1) -1 0); do short_hash=$(git rev-parse --short stash@{$i}); timestamp=$(date +%s%3N); refspec=\"s
tash@{$i}:refs/stashes/$email/${timestamp}_${short_hash}\"; refspecs=\"$refspecs $refspec\"; sleep 1; done; git push origin --no-verify $refspecs; }; f"
sti = "!f() { email=$(git config --get user.email); for ref in $(git for-each-ref --format=\"%(refname)\" \"refs/stashes/$email\"); do git update-ref -d \"$ref\"; done; git stash clear; git stup; for stash in $(git for-each-r
ef --format=\"%(refname)\" \"refs/stashes/$email\"); do git stash store --message \"$(git show --no-patch --format=%s $stash)\" \"$stash\"; done; }; f"
stl = stash list
stm = "!f() { email=$(git config --get user.email); git stash -u -m && git push --no-verify origin stash@{0}:refs/stashes/$email/$(date +%s%3N)_$(git rev-parse --short stash@{0}); }; f"
stp = "!f() { email=$(git config --get user.email); ref_to_delete=$(git ls-remote origin \"refs/stashes/$(git config --get user.email)/*$(git rev-parse --short stash@{0})\" | awk '{print $2}'); git push origin --delete \"$ref
_to_delete\" || true && git stash pop ${1:-0}; }; f"
stu = "!f() { email=$(git config --get user.email); git stash -u && git push --no-verify origin stash@{0}:refs/stashes/$email/$(date +%s%3N)_$(git rev-parse --short stash@{0}); }; f"
stup = "!f() { email=$(git config --get user.email); git fetch origin \"refs/stashes/$email/*:refs/stashes/$email/*\"; }; f"
[core]
autocrlf = false
editor = nano
longpaths = true
ignorecase = false
[push]
autoSetupRemote = true
[init]
defaultBranch = main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment