Github Branch,标记:如何获取特定版本的代码?
问题描述:
我是Git Hub新手,对标签和分支的概念感到困惑(解释为here) 我想从git hub获得稳定版本的PhantomJS(版本2.1.0)。但我不明白,如果我应该做的:Github Branch,标记:如何获取特定版本的代码?
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
我希望这有助于