Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show current git branch using the 'git branch' command

Tags:

git

I have a problem when working on too many branches, it takes a lot of time to find which is the current branch I am working on right now. Is there a way to list the current branch on top of the list that shows up when using the git branch command?

like image 451
Duilio Avatar asked May 14 '20 21:05

Duilio


People also ask

What is my current git branch?

Your answer You can run the git branch command in your CMD. It should show all the local branches of your repo. The starred branch is your current branch.

What is the command to see all the branches in git?

Command #1: git branch -r This Git command will show you remote branches.

How do I show a remote branch?

To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .

What is git branch command?

The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.


1 Answers

If you just want the checked-out branch, use git branch --show-current.

like image 61
chepner Avatar answered Oct 24 '22 10:10

chepner