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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 12. 獲得舊版本 ## 目的 > 學習如何檢出工作目錄中的先前快照。 在歷史中回憶很容易。`checkout` 命令將從倉庫復制任意快照 到工作目錄。 ### 獲得先前版本的哈希 ``` $ git hist ``` 注意:你記得在 `.gitconfig` 文件中定義的 `hist`,對嗎?如果 不是這樣,那么回顧一下有關別名的實驗。 ``` $ git hist * 1f7ec5e 2013-04-13 | Added a comment (HEAD, master) [Jim Weirich] * 582495a 2013-04-13 | Added a default value [Jim Weirich] * 323e28d 2013-04-13 | Using ARGV [Jim Weirich] * 9416416 2013-04-13 | First Commit [Jim Weirich] ``` 檢查日志輸出,并找到第一個提交的哈希。它應當在 `git hist` 輸出的最后一行。在下面的命令中使用哈希碼(前 7 個字符就 夠了)。然后檢查 hello.rb 文件的內容。 ``` $ git checkout <hash> $ cat hello.rb ``` 注意:這兒給的是 Unix 命令,適用于 Mac 和 Linux 系統。不幸 的是,Windows 用戶必須換成他們的原生命令。 注意:許多命令都需要倉庫中的哈希值。因為你的哈希值將與我的 不同,當你看到命令中的 `<hash>` 或 `<treehash>` 時,使用你 倉庫的正確哈希值替換。 你應該看到: ``` $ git checkout 9416416 Note: checking out '9416416'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at 9416416... First Commit $ cat hello.rb puts "Hello, World" ``` 在 Git 中的“detached HEAD”信息意味著 HEAD (Git 跟蹤當前目錄 應當匹配的那部分)是直接指向提交而非分支。在你沒有切換到不同 的分支時,這種狀態只會記得已經提交的更改。一旦你檢出了新的 分支或標簽,分離的提交將被丟棄 (因為 HEAD 已經移走)。如果你 想要保存在分離狀態的提交,那么你需要創建分支來記住提交。 Git 的舊版本將抱怨分離的 HEAD 狀態不在本地分支。現在不用擔心 這種情況。 注意 hello.rb 文件是最原始的內容。 ### 回到在 master 分支中的最新版本 ``` $ git checkout master $ cat hello.rb ``` 你應該看到: ``` $ git checkout master Previous HEAD position was 9416416... First Commit Switched to branch 'master' $ cat hello.rb # Default is "World" name = ARGV.first || "World" puts "Hello, #{name}!" ``` `master` 是默認分支的名稱。通過名稱檢出分支,你能夠回到 該分支的最新版本。
                  <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>

                              哎呀哎呀视频在线观看