Git学习笔记之Git 别名

Git 并不会在你输入部分命令时自动推断出你想要的命令。 如果不想每次都输入完整的 Git 命令,可以通过 git config 文件来轻松地为每一个命令设置一个别名。命令:

bash 复制代码
 git config --global alias.别名 命令

例如

bash 复制代码
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 commit 时,只需要输入 git ci。

几种用法:

为了解决取消暂存文件的易用性问题,可以向 Git 中添加你自己的取消暂存别名:

bash 复制代码
git config --global alias.unstage 'reset HEAD --'

这会使下面的两个命令等价:

bash 复制代码
git unstage fileA
git reset HEAD -- fileA

查看最后一次提交:

bash 复制代码
git config --global alias.last 'log -1 HEAD'
git last
复制代码
    
    
    
相关推荐
@小匠1 天前
Read Frog:一款开源的 AI 驱动浏览器语言学习扩展
人工智能·学习
炽烈小老头1 天前
【 每天学习一点算法 2026/04/12】x 的平方根
学习·算法
阿杰学AI1 天前
AI核心知识115—大语言模型之 自监督学习(简洁且通俗易懂版)
人工智能·学习·ai·语言模型·aigc·监督学习·自监督学习
渣渣馬1 天前
shell的if多条件
git·ssh
zh_xuan1 天前
Visual Studio 上传工程到github
ide·git·github·visual studio
九英里路1 天前
OS学习之路——动静态库制作与原理
linux·学习·操作系统·unix·进程·编译·动静态库
red_redemption1 天前
自由学习记录(160)
学习
南無忘码至尊1 天前
Unity学习90天-第2天-认识Unity生命周期函数并用 Update 控制物体移动,FixedUpdate 控制物理
学习·unity·游戏引擎
报错小能手1 天前
ios开发方向——swift错误处理:do/try/catch、Result、throws
开发语言·学习·ios·swift
AntoineGriezmann1 天前
Git 学习笔记
git