善用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

相關文章
相關標籤/搜索