善用Git alias 提升工做效率

背景

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

收益

大幅提升效率,好比:github

  • git status -> git st
  • git pull --> rebase origin master -> git pr
  • git check out -> git co
  • git branch -> git br

配置别名

  • 输入命令
vim ~/.gitconfig
复制代码
  • 添加内容
[alias]
        st = status
        co = checkout
        ci = commit
        cim = commit -m
        df = diff
        br = branch
        pr = pull --rebase origin master
        pl = pull
        ps = push
        ct = commit
        lg = log --stat
        lgp = log --stat -p
        lgg = log --graph
        lgga = log --graph --decorate --all
        lgm = log --graph --max-count=10
        lo = log --oneline --decorate       
        lol = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
        lola = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all    
        log = log --oneline --decorate --graph
        loga = log --oneline --decorate --graph --all
复制代码

更过优质内容:请点击vim

相关文章
相关标签/搜索