Does git log --branches work?

前端 未结 5 979
北荒
北荒 2020-12-28 12:44

I can\'t seem to get git log --branches to correctly filter its output. It seems as if Git ignores it.

For example, the head of git log --graph --

5条回答
  •  梦毁少年i
    2020-12-28 13:16

    Firstly, (the other) Adam is right that it doesn't make sense to use --all for this: if you only want to see one branch like your question states, why ask for all branches?

    Secondly, as already stated in comments to other answers, you don't need --branches; just do git log mybranch.

    Thirdly, I can explain why git log --branches=mybranch doesn't work. The git-log(1) man page says:

    --branches[=]
        Pretend as if all the refs in refs/heads are listed on
        the command line as . If  is given, 
        limit branches to ones matching given shell glob. If 
        pattern lacks ?, *, or [, /* at the end is implied.
    

    The last sentence is the crucial point here. If the is just mybranch then there is no globbing character, so git-log interprets it as if you'd typed

    git log --branches=mybranch/*
    

    which only matches references under $repo/.git/refs/heads/mybranch/*, i.e. branches which begin with mybranch/.

    There is a dirty hack to prevent the /* from being assumed:

    git log --branches=[m]ybranch
    

    but I can't think of any good reason why you would want to do this rather than just typing

    git log mybranch
    

提交回复
热议问题