在 Git 中配置 Aliases(别名) 是提高开发效率的神器。它不仅能让你少敲键盘,还能把复杂的命令组合成简单易记的短指令。
终端执行:git config --global --edit
下面列出了我个人在使用 Git 时发现的一些提高生产力的别名。你可以直接使用它们,或者根据需要进行修改。
bash
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
st = status
aa = add -A .
unstage = reset --soft HEAD^
cm = commit -m
amend = commit --amend -m
fix = commit --fixup
undo = reset HEAD~1
rv = revert
cp = cherry-pick
pu = !git push origin `git branch --show-current`
fush = push -f
flush = push --force-with-lease
mg = merge --no-ff
rb = rebase
rbc = rebase --continue
rba = rebase --abort
rbs = rebase --skip
rom = !git fetch && git rebase -i origin/master --autosquash
save = stash push
pop = stash pop
apply = stash apply
rl = reflog