Reputation: 1994
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. 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?
Upvotes: 9
Views: 16505
Reputation: 3323
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
So, git clone https://github.com/ariya/phantomjs.git
will clone project
If you have forked project you can do
git clone https://github.com/<YOUR_USERNAME>/phantomjs.git
Now change directory to phantomjs: cd phantomjs/
To see history you can execute git log
or git log --oneline --decorate --graph
for prettier view
To list all tags on repository execute
git tag
Finally, to create branch with tag 2.1.0 execute
git checkout 2.1.0 -b v2.1.0
After this you will have two branches master
and v2.1.0
I hope this helps
Upvotes: 2
Reputation: 3775
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.
Upvotes: 9