git alias config 配置

400 阅读1分钟

git 快捷方式配置

新建一个脚本快速执行配置


touch ~/gitconfig.sh

chmod +x ~/gitconfig.sh

将下列内容保存到 ~/gitconfig.sh


touch ~/.gitingore_global

git config --global alias.st status

git config --global alias.co checkout

git config --global alias.br 'branch'

git config --global alias.mg 'merge'

git config --global alias.ci 'commit'

git config --global alias.last 'log -1 HEAD'

git config --global alias.ls 'log --pretty=format:\"%C(yellow)%h %C(blue)%ad %C(red)%d %C(reset)%s %C(green)[%cn]\" --decorate --date=short'

git config --global alias.lg 'log --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'

git config --global alias.hist 'log --pretty=format:\"%C(yellow)%h %C(red)%d %C(reset)%s %C(green)[%an] %C(blue)%ad\" --topo-order --graph --date=short'

git config --global alias.latest 'for-each-ref --sort=-committerdate --format=\"%(committername)@%(refname:short) [%(committerdate:short)] %(contents)\"'

git config --global alias.master 'checkout master'

git config --global alias.dev 'checkout dev'

git config --global alias.test 'checkout test'

git config --global user.name '<YOUR NAME>'

git config --global user.email '<YOUR EMAIL>'

git  config  --global core.excludesfile  ~/.gitingore_global

echo '.DS_Store' > ~/.gitingore_global

echo 'GIT CONFIG RESULT:\n'

git config --list

执行~/gitconfig.sh