I clone my source using git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git w/
. Then I specify a specific branch/tag by doing git checkout <tag name>
or git checkout origin/REL<release number>
. Sometimes I forget what branch or tag I'm on.
In SVN I would do a svn info
to figure out what branch/tag I'm using (I realize that git has distinct definitions for branch
and tag
but for my purposes they are the same).
How do I determine what branch/tag I am on?
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.
Find Latest Git Tag Available In order to find the latest Git tag available on your repository, you have to use the “git describe” command with the “–tags” option. This way, you will be presented with the tag that is associated with the latest commit of your current checked out branch.
Checking out branches Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch. Think of it as a way to select which line of development you're working on.
Using git checkout with Tags By providing the tag's name as a parameter, Git will checkout that tag's revision. However, this might not be what you actually wanted, because your local repository is now in a "Detached HEAD" state! This means that the HEAD pointer is currently NOT on a branch, but on a specific revision.
git branch
tells you what branch you're on (with a *
marker).
Tags are just names for revisions, so Git won't tell you that you're "on" a tag, but you can use git name-rev HEAD
to get a sense for what it might be.
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