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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## git branch 列出、創建與管理工作上下文 ? ?git checkout 切換到新的分支上下文 `git branch`?命令是 Git 中的通用分支管理工具,可以通過它完成多項任務。 我們先說你會用到的最多的命令 —— 列出分支、創建分支和刪除分支。 我們還會介紹用來切換分支的?`git checkout`?命令。 ### git branch?列出可用的分支 沒有參數時,`git branch`?會列出你在本地的分支。你所在的分支的行首會有個星號作標記。 如果你開啟了[彩色模式](http://git-scm.com/book/en/Customizing-Git-Git-Configuration#Colors-in-Git),當前分支會用綠色顯示。 ~~~ $ git branch * master ~~~ 此例的意思就是,我們有一個叫做“master”的分支,并且該分支是當前分支。 當你執行?`git init`?的時候,缺省情況下 Git 就會為你創建“master”分支。 但是這名字一點特殊意味都沒有 —— 事實上你并不非得要一個叫做“master”的分支。 不過由于它是缺省分支名的緣故,絕大部分項目都有這個分支。 ### git branch (branchname)?創建新分支 我們動手創建一個分支,并切換過去。執行?`git branch (branchname)`?即可。 ~~~ $ git branch testing $ git branch * master testing ~~~ 現在我們可以看到,有了一個新分支。當你以此方式在上次提交更新之后創建了新分支,如果后來又有更新提交, 然后又切換到了“testing”分支,Git 將還原你的工作目錄到你創建分支時候的樣子 —— 你可以把它看作一個記錄你當前進度的書簽。讓我們實際運用看看 —— 我們用?`git checkout (branch)`?切換到我們要修改的分支。 ~~~ $ ls README hello.rb $ echo 'test content' > test.txt $ echo 'more content' > more.txt $ git add *.txt** $ git commit -m 'added two files' [master 8bd6d8b] added two files 2 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 more.txt create mode 100644 test.txt $ ls README hello.rb more.txt test.txt $ git checkout testing Switched to branch 'testing' $ ls README hello.rb ~~~ 當我們切換到“測試”分支的時候,我們添加的新文件被移除了。切換回“master”分支的時候,它們有重新出現了。 ~~~ $ ls README hello.rb $ git checkout master Switched to branch 'master' $ ls README hello.rb more.txt test.txt ~~~ ### git checkout -b (branchname)?創建新分支,并立即切換到它 通常情況下,你會更希望立即切換到新分支,從而在該分支中操作,然后當此分支的開發日趨穩定時, 將它合并到穩定版本的分支(例如“master”)中去。 執行?`git branch newbranch; git checkout newbranch`?也很簡單, 不過 Git 還為你提供了快捷方式:`git checkout -b newbranch`。 ~~~ $ git branch * master $ ls README hello.rb more.txt test.txt $ git checkout -b removals Switched to a new branch 'removals' $ git rm more.txt rm 'more.txt' $ git rm test.txt rm 'test.txt' $ ls README hello.rb $ git commit -am 'removed useless files' [removals 8f7c949] removed useless files 2 files changed, 0 insertions(+), 2 deletions(-) delete mode 100644 more.txt delete mode 100644 test.txt $ git checkout master Switched to branch 'master' $ ls README hello.rb more.txt test.txt ~~~ 如你所見,我們創建了一個分支,在該分支的上下文中移除了一些文件,然后切換回我們的主分支,那些文件又回來了。 使用分支將工作切分開來,從而讓我們能夠在不同上下文中做事,并來回切換。 創建新分支,在其中完成一部分工作,完成之后將它合并到主分支并刪除。你會覺得這很方便,因為這么做很快很容易。 如此,當你覺得這部分工作并不靠譜,舍棄它很容易。并且,如果你必須回到穩定分支做些事情, 也可以很方便地這個獨立分支的工作先丟在一邊,完成要事之后再切換回來。 ### git branch -d (branchname)?刪除分支 假設我們要刪除一個分支(比如上例中的“testing”分支,該分支沒啥特殊的內容了), 可以執行?`git branch -d (branch)`?把它刪掉。 ~~~ $ git branch * master testing $ git branch -d testing Deleted branch testing (was 78b2670). $ git branch * master ~~~ > **簡而言之**?使用?`git branch`?列出現有的分支、創建新分支以及刪除不必要或者已合并的分支。
                  <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>

                              哎呀哎呀视频在线观看