<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 配置別名 有沒有經常敲錯命令?比如`git status`?`status`這個單詞真心不好記。 如果敲`git st`就表示`git status`那就簡單多了,當然這種偷懶的辦法我們是極力贊成的。 我們只需要敲一行命令,告訴Git,以后`st`就表示`status`: ``` $ git config --global alias.st status ``` 好了,現在敲`git st`看看效果。 當然還有別的命令可以簡寫,很多人都用`co`表示`checkout`,`ci`表示`commit`,`br`表示`branch`: ``` $ git config --global alias.co checkout $ git config --global alias.ci commit $ git config --global alias.br branch ``` 以后提交就可以簡寫成: ``` $ git ci -m "bala bala bala..." ``` `--global`參數是全局參數,也就是這些命令在這臺電腦的所有Git倉庫下都有用。 在[撤銷修改](/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001374831943254ee90db11b13d4ba9a73b9047f4fb968d000)一節中,我們知道,命令`git reset HEAD file`可以把暫存區的修改撤銷掉(unstage),重新放回工作區。既然是一個unstage操作,就可以配置一個`unstage`別名: ``` $ git config --global alias.unstage 'reset HEAD' ``` 當你敲入命令: ``` $ git unstage test.py ``` 實際上Git執行的是: ``` $ git reset HEAD test.py ``` 配置一個`git last`,讓其顯示最后一次提交信息: ``` $ git config --global alias.last 'log -1' ``` 這樣,用`git last`就能顯示最近一次的提交: ``` $ git last commit adca45d317e6d8a4b23f9811c3d7b7f0f180bfe2 Merge: bd6ae48 291bea8 Author: Michael Liao <askxuefeng@gmail.com> Date: Thu Aug 22 22:49:22 2013 +0800 merge & fix hello.py ``` 甚至還有人喪心病狂地把`lg`配置成了: ``` git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" ``` 來看看`git lg`的效果: ![git-lg](img/00138492662982594cbd1a942114472aeeb5f0a502faed1000.png) 為什么不早點告訴我?別激動,咱不是為了多記幾個英文單詞嘛! ## 配置文件 配置Git的時候,加上`--global`是針對當前用戶起作用的,如果不加,那只針對當前的倉庫起作用。 配置文件放哪了?每個倉庫的Git配置文件都放在`.git/config`文件中: ``` $ cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "origin"] url = git@github.com:michaelliao/learngit.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [alias] last = log -1 ``` 別名就在`[alias]`后面,要刪除別名,直接把對應的行刪掉即可。 而當前用戶的Git配置文件放在用戶主目錄下的一個隱藏文件`.gitconfig`中: ``` $ cat .gitconfig [alias] co = checkout ci = commit br = branch st = status [user] name = Your Name email = your@email.com ``` 配置別名也可以直接修改這個文件,如果改錯了,可以刪掉文件重新通過命令配置。 ## 小結 給Git配置好別名,就可以輸入命令時偷個懶。我們鼓勵偷懶。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看