Github Branch,标签:如何获取代码的特定版本?

Ale*_*lex 5 git github git-tag git-branch

我是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
Run Code Online (Sandbox Code Playgroud)

要么

git init
git remote add -t 2.1 -f origin https://github.com/ariya/phantomjs.git
git checkout 2.1
Run Code Online (Sandbox Code Playgroud)

你能解释一下,为什么?

Fro*_*don 5

您应该只是克隆存储库,然后签出标记:

$ git clone https://github.com/ariya/phantomjs.git
$ cd phantomjs
$ git checkout 2.1
Run Code Online (Sandbox Code Playgroud)

请记住,在标记上,您不能提交任何本地更改.为此,你必须在一个分支上.令人困惑的是该命令git checkout适用于分支和标记.