Skip to content

Instantly share code, notes, and snippets.

@nikostoulas
Last active January 23, 2023 08:57
Show Gist options
  • Save nikostoulas/85eb028dc7c7f281fb84cd81bedfb071 to your computer and use it in GitHub Desktop.
Save nikostoulas/85eb028dc7c7f281fb84cd81bedfb071 to your computer and use it in GitHub Desktop.
Github aliases
# To make it easier to work on a anti git flow branching model described here: http://endoflineblog.com/gitflow-considered-harmful
# the following aliases have been created
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset [%C(dim cyan)%ad%Creset] %C(dim green)%an%Creset: %C(bold dim white)%s%Creset %C(auto)%d%Creset' --date=short
make-hotfix = !git stash && git hotfix-create $1 && git stash pop && :
graph = log --graph --color --pretty=format:'%Cred%h%Creset [%C(dim cyan)%cr%Creset] %C(dim green)%an%Creset: %C(bold dim white)%s%Creset %C(auto)%d%Creset'
tree = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset) %C(auto)%d%C(reset)\n %C(dim cyan)[%cr]%C(reset) %x09%C(dim cyan)%an:%C(reset) %C(bold cyan)%s %C(reset)'
hotfix-create = "!f() {\
red=`tput setaf 1`;\
yellow=`tput setaf 3`;\
reset=`tput sgr0`;\
run() {\
echo "${yellow}-\\> $@ ...${reset}";\
eval $@;\
return $?;\
};\
if [ -z "$1" ]; then echo "No branch name given"; exit 1; fi;\
run git fetch origin --tags --prune;\
run git checkout -b $1 `git rev-list --tags --max-count=1`;\
}; f"
hotfix-close = "!f() {\
red=`tput setaf 1`;\
yellow=`tput setaf 3`;\
reset=`tput sgr0`;\
run() {\
echo "${yellow}-\\> $@ ...${reset}";\
eval $@;\
return $?;\
};\
if [ -z "$1" ]; then echo "No branch name given"; exit 1; fi;\
if [ -z "$2" ]; then echo "No tag version given"; exit 1; fi;\
run git fetch origin --tags --prune;\
run git checkout $1;\
run git rebase `git rev-list --tags --max-count=1`;\
if [ $? -ne 0 ]; then\
echo "${red} Rebase to latest tag failed, aborting. Please fix rebase manually and try again."; \
exit 1;\
fi;\
run git tag $2;\
run git checkout master;\
run git pull;\
run git merge $1;\
if [ $? -ne 0 ]; then\
echo "${red} Merge with master failed, aborting. Please fix merge manually and do the following: ${reset}";\
echo "Please run ${yellow} git push origin refs/heads/$1:refs/heads/$1 -f ${reset}";\
echo "Please run ${yellow} git push-all ${reset}";\
echo "Please run ${yellow} git delete-branch $1 ${reset}";\
exit 1;\
fi;\
if [[ $3 == "-f" ]]; then\
run git push origin refs/heads/$1:refs/heads/$1 -f;\
run git push-all;\
run git delete-branch $1;\
else \
echo "Please run ${red} git push origin refs/heads/$1:refs/heads/$1 -f ${reset}";\
echo "Please run ${red} git push-all ${reset}";\
echo "Please run ${red} git delete-branch $1 ${reset}";\
echo "You could have run with -f as third param to automatically run the above.";\
fi;\
}; f"
delete-tag = !git tag -d $1 && git push origin :refs/tags/$1 && :
feature-create = "!f() {\
red=`tput setaf 1`;\
yellow=`tput setaf 3`;\
reset=`tput sgr0`;\
run() {\
echo "${yellow}-\\> $@ ...${reset}";\
eval $@;\
return $?;\
};\
if [ -z "$1" ]; then echo "No branch name given"; exit 1; fi;\
run git fetch origin --tags --prune;\
run git checkout master && run git pull && run git checkout -b $1;\
}; f"
feature-close = "!f() {\
red=`tput setaf 1`;\
yellow=`tput setaf 3`;\
reset=`tput sgr0`;\
run() {\
echo "${yellow}-\\> $@ ...${reset}";\
eval $@;\
return $?;\
};\
red=`tput setaf 1`;\
yellow=`tput setaf 3`;\
reset=`tput sgr0`;\
if [ -z "$1" ]; then echo "No branch name given"; exit 1; fi;\
run git fetch origin --tags --prune;\
run git checkout $1;\
run git rebase origin/master;\
if [ $? -ne 0 ]; then\
echo "${red} Rebase to master failed, aborting. Please fix rebase manually and try again."; \
exit 1;\
fi;\
run git checkout master;\
run git pull;\
run git merge $1;\
if [ $? -ne 0 ]; then\
echo "${red} Merge with master failed, aborting. Please fix merge manually and do the following: ${reset}";\
echo "Please run ${yellow} git push origin refs/heads/$1:refs/heads/$1 -f ${reset}";\
echo "Please run ${yellow} git push-all ${reset}";\
echo "Please run ${yellow} git delete-branch $1 ${reset}";\
exit 1;\
fi;\
if [[ $2 == "-f" ]]; then\
run git push origin refs/heads/$1:refs/heads/$1 -f;\
run git push-all;\
run git delete-branch $1;\
else \
echo "Please run ${red} git push origin refs/heads/$1:refs/heads/$1 -f ${reset}";\
echo "Please run ${red} git push-all ${reset}";\
echo "Please run ${red} git delete-branch $1 ${reset}";\
echo "You could have run with -f as second param to automatically run the above.";\
fi;\
}; f"
push-all = !git push --tags && git push
delete-branch = !git branch -d $1 && git push origin :refs/heads/$1 && :
release-create = !git feature-create $1
release-close = "!f() {\
red=`tput setaf 1`;\
yellow=`tput setaf 3`;\
reset=`tput sgr0`;\
run() {\
echo "${yellow}-\\> $@ ...${reset}";\
eval $@;\
return $?;\
};\
if [ -z "$1" ]; then echo "No branch name given"; exit 1; fi;\
if [ -z "$2" ]; then echo "No tag version given"; exit 1; fi;\
run git feature-close $1 && git tag $2;\
}; f"
@alkiskal
Copy link

@nikostoulas
Copy link
Author

Remove tags not in remote
git tag -l | xargs git tag -d && git fetch -t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment