[ACCEPTED]-How do I determine what branch/tag I have checked out in git?-tagging
git branch
tells you what branch you're on (with a 4 *
marker).
Tags are just names for revisions, so 3 Git won't tell you that you're "on" a tag, but 2 you can use git name-rev HEAD
to get a sense for what it 1 might be.
The current branch is marked with a *
in 1 the output of git branch
. Example:
$ git branch
branch1
* branch2
master
How do I determine what branch/tag I am 14 on?
First, since Git 2.22 (Q2 2019), you have git branch --show-current
which directly shows 13 you your current checked out branch.
Second, it 12 won't show anything if you are in a checked 11 out worktree (created with git worktree add
)
For that, check Git 2.23 10 (Q3 2019), with its "git branch --list
" which learned 9 to show branches that are checked out in 8 other worktrees connected to the same repository 7 prefixed with '+
', similar to the way the 6 currently checked out branch is shown
with 5 '*
' in front.
Example:
See commit 6e93814, commit ab31381, commit 2582083 (29 Apr 2019) by 4 Nickolai Belakovski (``).
(Merged by Junio C Hamano -- gitster
-- in commit 99eea64, 09 Jul 2019)
branch
: addworktree
info on verbose outputTo display worktree path for refs checked 3 out in a linked worktree
The git branch
documentation now states:
The 2 current branch will be highlighted in green 1 and marked with an asterisk.
Any branches checked out in linked worktrees will be highlighted in cyan and marked with a plus sign.
If you use the bash shell, you can use __git_ps1
in your bash prompt to show 3 this, for example:
[me@myhost:~/code/myproject] (master)$ ls
Download git-completion.bash
to ~/.git-completion.bash
Then in your 2 ~/.bashrc
file, add
source ~/.git-completion.bash
Then set your PS1
value to something 1 including $(__git_ps1 "(%s)")
, something like:
PS1="[\u@\h:\w]\$(__git_ps1)\\$ "
Why not consider using a nice prompt for 5 your shell?
Starship for Bash or Oh My Zsh for Zsh, or several 4 superb ones are out there.
I'm in love with 3 starship personally :)
https://github.com/CrazyOptimist/dotfiles
You will keep track 2 of more than git branch info once you adopt 1 one.
git branch
using this command tells you at what branch 1 you are by an *
marker.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.