Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current branch name in Git?

I'm from a Subversion background and, when I had a branch, I knew what I was working on with "These working files point to this branch".

But with Git I'm not sure when I am editing a file in NetBeans or Notepad++, whether it's tied to the master or another branch.

There's no problem with git in bash, it tells me what I'm doing.

like image 518
mike628 Avatar asked Jun 05 '11 20:06

mike628


People also ask

What is git branch name?

A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master . As you start making commits, you're given a master branch that points to the last commit you made. Every time you commit, the master branch pointer moves forward automatically.

How do I find a specific branch in git?

There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.


1 Answers

To display the current branch you're on, without the other branches listed, you can do the following:

git rev-parse --abbrev-ref HEAD 

Reference:

  • Show just the current branch in Git (Sep 2009)
like image 108
Jistanidiot Avatar answered Sep 23 '22 03:09

Jistanidiot