9 ms·
If your solution to "get the current branch" is "cat out this magic data file that happens to exist in the data directory" then we have completely incompatible
by stevelosh 14y ago
If your solution to "get the current branch" is "cat out this magic data file that happens to exist in the data directory" then we have completely incompatible definitions of "user interface" and are never going to agree on this.
- wonderzombie 14y agoThe question was not how to just get the current branch, thought, right? As pointed out already, `git branch` does that. The question was how to do it programmatically, and there are multiple ways to do it. You might still call that user interface, but it's that's a stretch; fancy shell magic like branch-in-prompt is typically write-once.
- Anderkent 14y ago`git branch` doesnt do that. `git branch | less` followed by search might, if I remember some part of the branch name well enough to search for it. Printing all the branches and having me scroll two screens up to find the one that's in color is not a solution to 'what branch am i on'
- fr0sty 14y agogit branch gives you a nice asterisk too: $git branch * MyBranch NotMyBranch It prints the branch as the first line of git status: $git status # On branch Foo ... It also ships with a 'bash-competion' file which gives you a very simple way to disply the current branch (among other things) rather simply. And of course you can also create your own alias if it is something you wish to do often.
- philwelch 14y agoWhy are you keeping hundreds of branches open at a time?
- kyrias 14y agoIf you want the branch in your prompt you should use the script that is shipped with git.