Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine what branch/tag I have checked out in git?

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?

like image 437
Avery Avatar asked Mar 25 '12 05:03

Avery


People also ask

How do I know my tag branch?

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.

How do you check which tag I am in git?

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.

What is a 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.

How do I checkout a specific tag?

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.


1 Answers

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.

like image 195
Amber Avatar answered Sep 24 '22 17:09

Amber