日常工作中经常用到 git 命令,敲久了难免会感到啰嗦、疲劳,比如
git push origin your_branch
git pull origin your_branch
git cherry-pick log
等等都是经常使用的,为此有必要给一些常用的命令进行缩写配置,提高工作效率。
当前项目配置别名
- 方式1:
git config alias.名字 "写上命令"
// 例如
git config alias.ps "push origin"
// 使用
git ps master
// git ps === git push origin master
- 方式2:
进入配置文件修改
(前提:要会基本的 vim 命令)
git config --edit
全局配置别名
- 方式1:
git config --global alias.名字 命令
// 例如
git config alias.ps "push origin"
// 使用
git ps
- 方式2:
进入配置文件修改
(前提:要会基本的 vim 命令)
git config --edit --global
删除别名
- 当前项目删除别名
// 例如
git config --unset alias.ps
// 或手动进入编辑删除掉
git config --edit
- 全局删除别名
// 例如
git config --unset --global alias.ps
// 或手动进入编辑删除掉
git config --edit --global
当前项目配置与全局配置的差别只在于
--global
选项