Last active
May 20, 2023 01:06
-
-
Save jnm2/4b8d6caaf85157ea9763e22e41185f2d to your computer and use it in GitHub Desktop.
This file contains 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 = jnm2 | |
email = [email protected] | |
[core] | |
pager = cat | |
autocrlf = true | |
editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin | |
[fetch] | |
prune = true | |
[alias] | |
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short -10 | |
bc = log origin/main..head --pretty=format:'- %s' --reverse | |
ec = config --global --edit | |
pushf = push --force-with-lease | |
wip = "!f() { if [[ -n \"$1\" ]]; then message=\"[wip] $1\"; else message=wip; fi; git add --all && git commit -m \"$message\"; }; f" | |
fpm = !" \ | |
function fetchAndPruneMerged { \ | |
git fetch --all --prune; \ | |
\ | |
for remoteName in upstream origin; \ | |
do \ | |
for branchName in HEAD dev develop main master '*'; \ | |
do \ | |
baseBranchName=$(git rev-parse --abbrev-ref --verify --quiet refs/remotes/$remoteName/$branchName); \ | |
[ $baseBranchName ] && break 2; \ | |
done; \ | |
done; \ | |
\ | |
[ $baseBranchName ] || { echo 'Cannot determine the default branch.'; return 1; }; \ | |
\ | |
currentRefName=$(git rev-parse --symbolic-full-name HEAD); \ | |
[ $(git for-each-ref --merged $baseBranchName --format 'nospaces' $currentRefName) ] && git checkout $baseBranchName; \ | |
\ | |
git for-each-ref --merged $baseBranchName --format '%(refname:short)' refs/heads | xargs --no-run-if-empty git branch -D; \ | |
}; fetchAndPruneMerged" | |
nb = !" \ | |
function newBranch { \ | |
[ $1 ] || { echo 'The name for the new branch must be specified.'; return 1; }; \ | |
\ | |
git fetch --all --prune; \ | |
\ | |
for remoteName in upstream origin; \ | |
do \ | |
for branchName in HEAD dev develop main master '*'; \ | |
do \ | |
baseBranchName=$(git rev-parse --abbrev-ref --verify --quiet refs/remotes/$remoteName/$branchName); \ | |
[ $baseBranchName ] && break 2; \ | |
done; \ | |
done; \ | |
\ | |
[ $baseBranchName ] || { echo 'Cannot determine the default branch.'; return 1; }; \ | |
\ | |
git checkout $baseBranchName -b $1; \ | |
}; newBranch" | |
notpushed = !" \ | |
function listBranchesNotPushed { \ | |
git fetch --all; \ | |
\ | |
for headRef in $(git for-each-ref --format='%(refname)' refs/heads); \ | |
do \ | |
[ \"$(git for-each-ref --count=1 --contains=\"$headRef\" refs/remotes)\" ] || echo ${headRef#refs/heads/}; \ | |
done; \ | |
}; listBranchesNotPushed" | |
[hub] | |
protocol = https | |
[init] | |
defaultBranch = main | |
[push] | |
autoSetupRemote = true | |
default = current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment