您好,登錄后才能下訂單哦!
今天想使用一下之前開源項目Blog_mini一個分支的代碼,于是把整個項目克隆下來:
xpleaf@leaf:~/test$ git clone https://github.com/xpleaf/Blog_mini 正克隆到 'Blog_mini'... remote: Counting objects: 1153, done. remote: Total 1153 (delta 0), reused 0 (delta 0), pack-reused 1153 接收對象中: 100% (1153/1153), 2.18 MiB | 238.00 KiB/s, 完成. 處理 delta 中: 100% (673/673), 完成. 檢查連接... 完成。
然后查看分支,發現竟然沒有之前創建的分支:
xpleaf@leaf:~/test/Blog_mini$ git branch * master
這是因為git clone命令默認就是克隆倉庫中master的代碼的,但是可以查看遠程倉庫的分支:
xpleaf@leaf:~/test/Blog_mini$ git branch -r origin/HEAD -> origin/master origin/master origin/version_1.0 xpleaf@leaf:~/test/Blog_mini$ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/version_1.0
然后再使用git checkout命令切換到自己期望的分支上:
xpleaf@leaf:~/test/Blog_mini$ git checkout remotes/origin/version_1.0 Note: checking out 'remotes/origin/version_1.0'. 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 目前位于 2ff197d... update README.md
于是就可以看到目前已經在分支version_1.0上了,相應的代碼也會克隆下來:
xpleaf@leaf:~/test/Blog_mini$ git branch * (頭指針分離于 origin/version_1.0) master xpleaf@leaf:~/test/Blog_mini$ ls app LICENSE migrations README.md requirements.txt config.py manage.py Procfile requirements
當然上面是用Github的例子來說明,實際上使用Gitlab或者其它自己搭的Git服務器也是可以的,因為使用的都是Git版本控制系統。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。