版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1340355
Git 配置别名 —— 让命令变得更简单
之前使用 Git 版本控制工具的时候,基本都是使用图形化工具,如 SourceTree,TortoiseGit (小乌龟),对 GIt 命令也不是很熟悉。后面由于工作的原因,切换到 Ubuntu 开发,不得已使用 Git 命令,而每次在提交代码的时候,都要敲一堆 Git 命令,有时候会忘了,效率相对来说比较低。查了相关的资料,了解dao Git 提供了别名 (alias) 功能,方便我们对常用的 Git 命令进行自定义封装。
配置 GIt 别名是使用 git config –global alias 命令来配置,比如 我想用 st 代表 status,name我们可以这样设置。
git config --global alias.st status
以后只需要输入git st,即可查看当前 git 仓库的状态
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.pl pull --rebase
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative"
git config --global alias.lga "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative --author xujun"
git config --global alias.last "log -1"
git config 文件的存放位置主要有三个位置。
git config --system user.name "xujun"
git config --system user.email “gdutxiaoxu@163.com"
git config --global user.name "xujun"
git config --global user.email “gdutxiaoxu@163.com"
在 Windows 系统上,Git 会找寻用户主目录下的 .gitconfig 文件。主目录即 $HOME 变量指定的目录,一般都是 C:\Users{UserName} 。此外,Git 还会尝试找寻 /mingw64/etc/gitconfig 文件,只不过看当初 Git 装在什么目录,就以此作为根目录来定位。 比如我的 git 安装目录是 C:\Program Files\Git, 那么相应的文件位置是C:\Program Files\Git\mingw64\etc 。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有