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?
Checkout Git Tag To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options. Let's say for example that you have a tag named “v1. 0” that you want to check out in a branch named “release”. Using this command, you have successfully checked out the “v1.
Tags and branch are completely unrelated, since tags refer to a specific commit, and branch is a moving reference to the last commit of a history.
How do I pull a specific commit? The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .
On GitHub.com, navigate to the main page of the repository. To the right of the list of files, click Releases . Click Draft a new release. Click Choose a tag, type a version number for your release, and press Enter. Alternatively, select an existing tag.
Branches are dynamic and code can be added to them. A tag is most typically used to mark a particular point in the commit ancestry chain. A branch is an active line of development whereas a tag is a reference to a specific commit on any branch.
#git #tags. Tags are a simple aspect of Git, they allow you to identify specific release versions of your code. You can think of a tag as a branch that doesn't change. Once it is created, it loses the ability to change the history of commits.
This is because, even if you’re switched to a branch on the website, Github only gives you the URL to download the repo from. It does not tell you how you should download it. If you take this URL, and run git clone, it will download the default branch, usually master.
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.
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 dogit 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 executegit tag
Finally, to create branch with tag 2.1.0 executegit checkout 2.1.0 -b v2.1.0
After this you will have two branches master
and v2.1.0
I hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With