[英]Github Branch,Tag: How to get a specific release of a code?
我是 Git hub 的新手,我對標簽和分支的概念感到困惑( 在此處解釋)我想從 git hub 獲得穩定版本的 PhantomJS(版本 2.1.0)。 但我不明白我是否應該這樣做:
git checkout master
git remote add upstream https://github.com/ariya/phantomjs.git
git fetch upstream
git rebase --onto tags/2.1.0 upstream/master master
或
git init
git remote add -t 2.1 -f origin https://github.com/ariya/phantomjs.git
git checkout 2.1
你能解釋一下是哪一個,為什么?
您應該只克隆存儲庫,然后簽出標簽:
$ git clone https://github.com/ariya/phantomjs.git
$ cd phantomjs
$ git checkout 2.1
請記住,在標簽上,您不能提交您將進行的任何本地更改。 為此,您必須在一個分支上。 令人困惑的是,該命令是分支和標簽的git checkout
。
我不確定我是否正確理解了您的問題,但我會嘗試回答:
Git 存儲有關代碼中所做的所有更改的數據(包括有關分支和標簽的數據)當您克隆存儲庫時,您將獲得該存儲庫的完整歷史記錄
所以, git clone https://github.com/ariya/phantomjs.git
將克隆項目
如果你有分叉項目,你可以做git clone https://github.com/<YOUR_USERNAME>/phantomjs.git
現在將目錄更改為 phantomjs: cd phantomjs/
要查看歷史記錄,您可以執行git log
或git log --oneline --decorate --graph
以獲得更漂亮的視圖
列出存儲庫上的所有標簽執行git tag
最后,創建標簽為 2.1.0 的分支,執行git checkout 2.1.0 -b v2.1.0
在此之后,您將擁有兩個分支master
和v2.1.0
我希望這會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.