1

In the latest version of git you can use the flag --branch (or -b) to "Show the branch and tracking info even in short-format."

When (which version) did git introduce this option? I know that at least in 1.7.0.4 it isn't an option.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
bryan kennedy
  • 6,969
  • 5
  • 43
  • 64
  • 1
    Why do you need to know? – Mat Oct 26 '11 at 21:29
  • So that my lazy git alias commands that I use in my bash scripts work across multiple computers with multiple versions of git. I have 'gs' aliases to 'git status -b' but it throws errors if the version of git is too old. I want to add a conditional to my bash file. Hacky, I know. – bryan kennedy Oct 26 '11 at 21:44

2 Answers2

3

The combination of git grep -F and git log --oneline -S is generally a powerful way to dig anything out of a Git repo:
(manojlds proposes in his answer a one-liner which should work most of the time if you search for the right comment like the OP's question does. Go upvote it).

VonC@NETVONC ~/Prog/git/git (master)
$ git grep -F 'Show the branch'
Documentation/git-status.txt:   Show the branch and tracking info even in short-format.

VonC@NETVONC ~/Prog/git/git (master)
$ git log --oneline --follow -S'Show the branch' -- Documentation/git-status.txt
46077fa Documentation+t5708: document and test status -s -b

VonC@NETVONC ~/Prog/git/git (master)
$ git tag --contains 46077fa
ko-maint
ko-master
ko-next
ko-pu
v1.7.2

So 1.7.2

(I always found this thread a neat illustration of git digging)


Note: It has been introduced 233 commits after 1.7.1 according to git describe:

VonC@NETVONC ~/Prog/git/git (master)
$ git describe 46077fa
v1.7.1-233-g46077fa

It was first introduced at Tue May 25 16:52:03 2010 +0200

VonC@NETVONC ~/Prog/git/git (master)
$ git show 46077fa

commit 46077fa5d477a3e96e0bb96042a2a9fdc9c818cb
Author: Michael J Gruber <git@drmicha.warpmail.net>
Date:   Tue May 25 16:52:03 2010 +0200

    Documentation+t5708: document and test status -s -b

    Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `git grep` doesn't need the `-e`, that is only needed when the pattern starts with `-` – manojlds Oct 27 '11 at 03:53
  • @manojlds: thank you (I have updated the answer), and +1 on your answer. I wanted to illustrate the combo `git grep` + `git log`, but, in this situation, your answer is more efficient. – VonC Oct 27 '11 at 04:10
2

I usually search for the strings and look for them in the release notes ( so that you know exactly which release it was added with just one command):

Something like this works:

$ git grep -F "shows the current branch"
Documentation/RelNotes/1.7.2.txt: * "git status -s -b" shows the current branch

Clearly, it was added in 1.7.2. Of course you have to play around with the words, but you can employ regexes to find more easily.

You can do similar search using github's advanced search, that way, you don't have to clone the source.

You can do soemthing like:

repo:git/git path:Documentation/RelNotes/* <what you want to find>

to search the release notes online

manojlds
  • 290,304
  • 63
  • 469
  • 417