0

I am listing commits that have been changing specific file with command

$ git log --all --graph --abbrev-commit --format=fuller  --follow <path_to_filename>

It displays a nicely formatted commits that include provided file name. However I had trouble finding the commit. I used

$ git branch --contains 10264d5

to find branch names that contain specific commit.

Is there a way to include branch name in git log command? I tried to use command recommended in this answer but it doesn't work with --filename argument.

Community
  • 1
  • 1
Miki
  • 2,438
  • 2
  • 26
  • 35
  • git log --graph --all --decorate duplicated: http://stackoverflow.com/questions/1841405/how-can-i-show-the-name-of-branches-in-git-log – Alejandro Rosero May 03 '16 at 13:15
  • @AlejandroRosero you clearly didn't read question or tried your advice by yourself. My link points to almost same command, which cannot be extended with --filename argument, as written in question. – Miki May 03 '16 at 13:29

2 Answers2

1

I do not believe it is possible. You can add the --decorate option, but that will just list the branch name if one of the logged commits just happens to be in refs/heads.

I believe you'd have to write your own custom wrapper to achieve this.

This is frustrating, and annoying. Some git people will respond by describing the git architecture and show how it is not easily possible, and in some more complicated situations, it has little meaning. I'm not disputing any of that, but it is something that many people would find useful and would increase their productivity.

Mort
  • 2,888
  • 1
  • 19
  • 33
1

Finding the same issue as you, I wrote a small bash wrapper for it.

It doesn't support many of the log options (graph and all being the most notable breakers), but most format options should work out of the box.

log_branch(){
    commit_list=$(git log --pretty="%H")
    for commit_hash in $commit_list;do
        show=$(git log -n 1 $commit_hash $@)
        branches=$(git branch --column --contain $commit_hash | sed -e 's/* /*/' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
        output=$(echo "$show" | sed "s@$commit_hash@$commit_hash {$branches}@")
        echo "$output"
    done
}

Uploaded to GitHub

vguzmanp
  • 754
  • 1
  • 10
  • 28