macpro 设置终端git的别名alias

720 阅读1分钟

背景

经常使用git的命令行工具进行项目管理,每次输入命令都要输入全称命令,有时候还输错,故我们给git的命令行命名为容易记忆简单的缩写,开发就很愉快了!
我使用的设备是macpro,故这里介绍的是macpro,windows和macpro设置过程差不多,大家自己查找下资料并试一下就可以了;

步骤

    1. 打开终端,输入cd ~,这个命令行是进入到你的电脑账户名下;
    1. 输入touch .bash_profile 这个命令可以达到,如果没有.bash_profile这个文件,则建立这个文件;如果有的话,就更新这个文件的更新时间;
    1. 输入命令行echo 'alias ga="git add"'>> ~/.bash_profile 这个命令可以把alias ga="git add"这个内容添加到.bash_profile这个文件内
  • 4.输入source ~/.bash_profile 这个命令可以使.bash_profile这个文件生效;这样你就可以使用别名ga来代替git add 了;我使用的是webstorm编辑器,里面使用的git是macpro系统的,所以我只改了这一个地方就可以了;
  • 5.我还使用了很多别名,如下
echo 'alias ga="git add"'>> ~/.bash_profile
echo 'alias gaa="git add ."'>> ~/.bash_profile
echo 'alias gs="git status"'>> ~/.bash_profile
echo 'alias gc="git commit"'>> ~/.bash_profile
echo 'alias gb="git branch"'>> ~/.bash_profile
echo 'alias gp="git push"'>> ~/.bash_profile