简体   繁体   English

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

[英]Github Branch,Tag: How to get a specific release of a code?

I'm new to Git hub and I got confused about the concept of tag and branch(explained here ) I would like to get an stable version of PhantomJS(version 2.1.0) from git hub.我是 Git hub 的新手,我对标签和分支的概念感到困惑( 在此处解释)我想从 git hub 获得稳定版本的 PhantomJS(版本 2.1.0)。 But I don't understand if I should do:但我不明白我是否应该这样做:

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

or

git init
git remote add -t 2.1 -f origin https://github.com/ariya/phantomjs.git
git checkout 2.1

Would you please explain me which one and why?你能解释一下是哪一个,为什么?

You should just clone the repository and then checkout the tag:您应该只克隆存储库,然后签出标签:

$ git clone https://github.com/ariya/phantomjs.git
$ cd phantomjs
$ git checkout 2.1

Keep in mind that being on a tag, you cannot commit any local change you would make.请记住,在标签上,您不能提交您将进行的任何本地更改。 For that, you must be on a branch.为此,您必须在一个分支上。 What can be confusing is that the command is git checkout for both branches and tags.令人困惑的是,该命令是分支和标签的git checkout

I am not sure if I understood your question correctly but I will try to answer on it:我不确定我是否正确理解了您的问题,但我会尝试回答:

Git stores data about all changes that made in code (this include data about branches and tags) When you clone a repository you will get complete history for that repository Git 存储有关代码中所做的所有更改的数据(包括有关分支和标签的数据)当您克隆存储库时,您将获得该存储库的完整历史记录

So, git clone https://github.com/ariya/phantomjs.git will clone project所以, git clone https://github.com/ariya/phantomjs.git将克隆项目
If you have forked project you can do如果你有分叉项目,你可以做
git clone https://github.com/<YOUR_USERNAME>/phantomjs.git

Now change directory to phantomjs: cd phantomjs/现在将目录更改为 phantomjs: cd phantomjs/

To see history you can execute git log or git log --oneline --decorate --graph for prettier view要查看历史记录,您可以执行git loggit log --oneline --decorate --graph以获得更漂亮的视图

To list all tags on repository execute列出存储库上的所有标签执行
git tag

Finally, to create branch with tag 2.1.0 execute最后,创建标签为 2.1.0 的分支,执行
git checkout 2.1.0 -b v2.1.0
After this you will have two branches master and v2.1.0在此之后,您将拥有两个分支masterv2.1.0

I hope this helps我希望这会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM