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
复制代码
    
    
    
相关推荐
_李小白13 小时前
【OSG学习笔记】Day 24: Texture2D 与 Image
android·笔记·学习
猹叉叉(学习版)13 小时前
【系统分析师_知识点整理】 12.系统设计
笔记·软考·系统设计·系统分析师
不会写DN13 小时前
Git 开发中最常用的命令与场景
大数据·git·elasticsearch
笨小古13 小时前
VLA学习笔记——持续更新中
学习·机器人·大模型·具身智能·vla
Rain_Rong13 小时前
禁止迅雷11更新
笔记
孙严Pay14 小时前
快捷支付和网关支付,到底有啥不一样?
笔记·科技·计算机网络·其他·微信
张二娃同学14 小时前
基于 Python 与 Tkinter 的猜数字游戏设计与实现:支持玩家猜数与 AI 反向推理
开发语言·git·python·游戏·开源
prog_610314 小时前
【笔记】用cursor手搓cursor(四)
人工智能·笔记·大语言模型·agent
solicitous14 小时前
遇到一个口头机遇的答辩准备2(ai告诉的要点)
学习·生活
313YPHU314 小时前
【笔记】Node.js 开发 CLI 工具
笔记