At the moment I use
git branch | grep \* | cut -d ' ' -f2-
But it's too slow in terms of execution time.
Is there a faster way to generate the same output?
And I mean identical output (I haven't seen any cases I dislike), e.g. detached heads
(HEAD detached at SHA)
rebasing
(no branch, rebasing BRANCH)
etc.
I already tried e.g.
cat .git/HEAD | cut -d '/' -f3
but I know that sometimes, e.g. if rebasing, that won't work. Then I would have to check for existence of .git/REBASE_HEAD
? Also there's the problem of locating the .git
directory from any subdirectory. In the end I don't know if a solution like this would be faster, at least probably not if I (with my inexperience) am the one to code it.