Why does `git branch` annotate a branch with `+` and another with `*`?
Asked Answered
M

1

0

When I do git branch, it returns something like:

~/Dev/project/main (main) $ git branch
  bug22
* main
+ feature33
  feature19
Miceli answered 25/8, 2022 at 11:9 Comment(0)
M
1

This is because you're using git worktrees.

  • * Whether or not you're using worktrees, * (always) annotates the current branch you've checked out.
  • + Annotates the branch that's checked out at your other worktrees.

like if I tried checking out feature33 then I would have got the following error:

fatal: 'feature33' is already checked out at '~/Dev/project/features'

Miceli answered 25/8, 2022 at 11:9 Comment(3)
@torek how do you know it was from 2.23? I don't see it mentioned hereMiceli
Git is open sore... er, source and stored in a Git repository: just clone it and look for the implementation with the history pickaxe tools. In this case a quick git log -S "plus sign" -- Documentation/git-branch.txt turns up the commit hash ID ab3138146f9ce1d819cefab4515965604de76d9d, and then git describe --contains tells you v2.23.0-rc0~95^2~1 and Bob's your uncle. It's a cake of pie, er, easy as cake.Sloop
@Sloop Thanks. That comment was gold. I learned about git log -S & git describe. Such a clever way to search for plus signMiceli

© 2022 - 2024 — McMap. All rights reserved.