美文网首页
git alias 配置

git alias 配置

作者: Yandhi233 | 来源:发表于2022-01-30 04:23 被阅读0次

通常在使用 git 命令时,要输入很长的命令,可以通过配置 git alias 提高效率

1. 创建别名

使用以下命令创建别名,替换为别名的名称和要别名的命令:<alias><command>

$  git config --global alias.<alias> <command>

也可以在 git 文本编辑器中打开 git 配置文件,一次性配置多个别名

$  git config --global -e

在打开的 .gitconfig 文件中追加,以下为部分别名,可自行修改配置

[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
  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

2. 查看所有 git 别名

$  git config -l | grep alias | sed 's/^alias\.//g'

相关文章

  • Git 2022-04-27

    使用 alias 这是我的 zshrc 的 alias 配置: alias gst='git status -sb...

  • git 使用

    git 全局配置 git config --global alias.st status git config -...

  • git配置 alias

    命令行设置git的配置 alias 配置 ~/.gitconfig 文件

  • 配置别名

    配置别名案例: git config --global alias.st status == git statu...

  • git常用操作

    git缩写配置: 在.gitconfig文件中添加: [alias] git常用操作: git clone 克隆一...

  • GIT配置和命令

    推荐使用 推荐配置成每个项目单独配置的方式: GIT设置ALIAS别名 GIT更新命令 GIT搜索 在commit...

  • git alias 配置

    通常在使用 git 命令时,要输入很长的命令,可以通过配置 git alias 提高效率 1. 创建别名 使用以下...

  • 我的git使用心得

    小推荐 Linux的shell配置,参考oh-my-zsh git alias的配置,可以参考这里 git ali...

  • zsh git 缩写

    alias ga='git add' alias gb='git branch' alias gba='git b...

  • Git 学习笔记(别名篇)

    配置命令别名 git config --global alias.别名 原名 效果如下所示: $ git conf...

网友评论

      本文标题:git alias 配置

      本文链接:https://www.haomeiwen.com/subject/ctkqkrtx.html