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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                >[info] git checkout 功能: - 撤銷修改 - 切換(檢出)分支 ### 撤銷修改: git checkout -- file可以丟棄工作區的修改: ``` $ git checkout -- readme.txt ``` 命令git checkout -- readme.txt意思就是,把readme.txt文件在工作區的修改全部撤銷,這里有兩種情況: 1. 一種是readme.txt自修改后還沒有被放到暫存區,現在,撤銷修改就回到和版本庫一模一樣的狀態; 2. 一種是readme.txt已經添加到暫存區后,又作了修改,現在,撤銷修改就回到添加到暫存區后的狀態。 >[info] 總之,就是讓這個文件回到最近一次git commit或git add時的狀態。 ### 切換分支 我們創建`dev`分支,然后切換到`dev`分支: ~~~ $ git checkout -b dev Switched to a new branch 'dev' ~~~ `git checkout`命令加上`-b`參數表示創建并切換,相當于以下兩條命令: ~~~ $ git branch dev $ git checkout dev Switched to branch 'dev' ~~~ 從下面的代碼可以得出,切換分支并沒有改變工作區哦 ~~~ Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (master) $ git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working tree clean Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (master) $ git checkout dev Switched to branch 'dev' Your branch is up-to-date with 'origin/dev'. Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (dev) $ git status On branch dev Your branch is up-to-date with 'origin/dev'. nothing to commit, working tree clean Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (dev) $ ls node.txt README.md test test2 test3 Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (dev) $ vi test Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (dev) $ git status On branch dev Your branch is up-to-date with 'origin/dev'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: test no changes added to commit (use "git add" and/or "git commit -a") Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (dev) $ git checkout master Switched to branch 'master' Your branch is up-to-date with 'origin/master'. Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (master) $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: test no changes added to commit (use "git add" and/or "git commit -a") Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (master) $ ~~~ 但是當在dev分支修改提交后,再回到master: ~~~ Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (master) $ vi test Administrator@USER-20160512VQ MINGW64 ~/desktop/github-note (master) $ git checkout dev error: Your local changes to the following files would be overwritten by checkout: test Please commit your changes or stash them before you switch branches. Aborting ~~~ 此時提示: ~~~   錯誤:您的本地更改以下文件將被檢出覆蓋:   測試   請提交您的更改或隱藏他們之前切換分支。   流產 ~~~ 結論:當檢出分支時發現本地更改會被檢出覆蓋時就不允許切換分支,除非按照提示解決問題。(即使git add test也還是會報錯哦) 咦,怎么感覺這個結論怪怪的呢。 至于上面你用那么長的代碼證明的結論已經不攻自破了,現在可以解釋了你那么結論的情況了,HEAD->master->commit,HEAD->dev->commit它們指向同一個提交的時,那時dev分支剛從master建立出來,它們都還沒有任何提交,它們的指針都同時指向了一個提交,也就是它們的版本庫是一模一樣的,或者說“它們就是一個人”,所以此時檢出分支當然內容相同,讓你感覺切換分支好像并沒有改變工作區一樣,其實這種情況當git發現兩個分支是指向同一個引用時根本就沒有做“檢出(工作區進行任何變化)”操作哦,只是切換一下當前分支而已,即改變/.git/HEAD里面的指向而已哈。 總結:當前工作是屬于分支的,如果你有未做完的工作(工作區不是干凈的:有未添加到暫存區的修改或者暫存區有內容),那么切換分支會失敗,除非是那種情況(“它們就是一個人”)。請做完工作(保證工作區是干凈的)或者隱藏現場在切換分支。
                  <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>

                              哎呀哎呀视频在线观看