您好,登錄后才能下訂單哦!
今天想使用一下之前開源項目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), 完成. 檢查連接... 完成。
然后查看分支,發(fā)現(xiàn)竟然沒有之前創(chuàng)建的分支:
xpleaf@leaf:~/test/Blog_mini$ git branch * master
這是因為git clone命令默認(rèn)就是克隆倉庫中master的代碼的,但是可以查看遠(yuǎn)程倉庫的分支:
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
于是就可以看到目前已經(jīng)在分支version_1.0上了,相應(yīng)的代碼也會克隆下來:
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
當(dāng)然上面是用Github的例子來說明,實際上使用Gitlab或者其它自己搭的Git服務(wù)器也是可以的,因為使用的都是Git版本控制系統(tǒng)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。