美文网首页
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 alias 配置

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