function GitAliasHelp()
{
echo "Hellp for git alias commands:"
echo " g.h alias for git help."
echo " g.add alias for git add."
echo " g.bs alias for git bisect."
echo " g.br alias for git branch."
echo " g.co alias for git checkout."
echo " g.cm alias for git commit."
echo " g.cl alias for git clone."
echo " g.df alias for git diff."
echo " g.ft alias for git fetch."
echo " g.grep alias for git grep."
echo " g.init alias for git init."
echo " g.log alias for git log."
echo " g.mg alias for git merge."
echo " g.mv alias for git mv."
echo " g.pl alias for git pull."
echo " g.ps alias for git push."
echo " g.rb alias for git rebase."
echo " g.rs alias for git reset."
echo " g.rm alias for git rm."
echo " g.rv revert all chanages for current working space."
echo " g.so alias for git show."
echo " g.ss alias for git status."
echo " g.tag alias for git tag."
echo ""
}
function GitRevertAll()
{
echo -n "All changes in the work space will be lost, are you sure? [Yes/No]: "
read m_input
if [ "$m_input" != "yes" ];then
return
fi
echo "Start revert deleted files ......"
git status | grep deleted | cut -d":" -f2 | xargs git checkout
echo "Start revert modified files ......"
git status | grep modified | cut -d":" -f2 | xargs git checkout
echo "All changes revert done."
return
}
# alias for git
alias g.h="git help; GitAliasHelp"
alias g.add="git add"
alias g.bs="git bisect"
alias g.br="git branch"
alias g.co="git checkout"
alias g.cm="git commit -s"
alias g.cl="git clone"
alias g.df="git diff"
alias g.ft="git fetch"
alias g.grep="git grep"
alias g.init="git init"
alias g.log="git log --all --graph --pretty=format:'%Cred%h%Creset%Cgreen [%ad] %C(bold blue)<%an> - %C(yellow)%d%Creset%s %Creset' --abbrev-commit --date=short"
alias g.mg="git merge"
alias g.mv="git mv"
alias g.pl="git pull"
alias g.ps="git push"
alias g.rb="git rebase"
alias g.rs="git reset"
alias g.rm="git rm"
alias g.rv="GitRevertAll"
alias g.so="git show"
alias g.ss="git status"
alias g.tag="git tag"
alias g.gc="git gc"
【Git Config】Git配置脚本