1

I would like to be able to see when file changes make it into a Git branch, i.e. when it was pushed/merged. I don't want to see the local commit date or the date it was pushed to a branch that I don't care about. If it was originally in another branch, then I want to know when that branch was merged in.

Is there a way to see this information in Git?

I need this so that I can quickly see which changes fall within a date/time range on that branch that could be contributing to integration test failures on that branch.

  • I don't understand what you are looking for. Perhaps you find something [here](https://stackoverflow.com/questions/47307978/difference-between-different-git-search-commands) – Christoph May 14 '18 at 17:04
  • I'm not trying to search for a particular pattern or string. I just want to see what changes got into the Git branch in a date/time range. – Travis Bruce May 14 '18 at 17:20
  • https://stackoverflow.com/questions/9725531/show-commits-since-branch-creation – Christoph May 14 '18 at 18:01
  • I don't think that's what I want either. I believe that will show me the commit dates. I want to know when the changes were pushed or merged into the branch, not the commit date. – Travis Bruce May 14 '18 at 18:23
  • git reflog --date=local branch_name https://stackoverflow.com/questions/6795070/is-there-a-way-in-git-to-obtain-a-push-date-for-a-given-commit – MarcH May 24 '18 at 16:13

1 Answers1

1

So, you want to see merges on the ancestry path to a commit whose first parent is not also on the ancestry path?

git rev-list --parents --ancestry-path --reverse $commit.. \
| awk BEGIN{seen[$commit]=1}' {seen[$1]=1}
      !seen[$2] {print $1}' \
| git log --no-walk --stdin

This runs the ancestry path oldest-first, i.e. the oldest commit with your desired commit as an ancestor first, then proceeding forwards. The awk marks your desired commit as already seen at startup, then each commit it sees on the way. Any commit whose first parent hasn't already been seen is guaranteed to be a merge that reaches your commit only through merged-in history.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • This does look like it gets the information I want, but only when I have a specific commit hash in mind. What I want would be this result, but for all commits in git log. Edit: Now I'm noticing this still shows the commit date, and not the push date. Ideally I want the push date. – Travis Bruce May 14 '18 at 20:16
  • It's showing you the date of the merge, not the merged commits. The merge is of all the merged commits. Git doesn't keep any permanent record of pushes, you can check reflogs on the receiving end. – jthill May 14 '18 at 20:21
  • Yep... doesn't looke like Git has a solution for this out-of-the-box. I feel like this would be a very common need in order to triage failures when working with remote repos and having CI processes that kick off regularly instead of for each commit. I did find this answer that has detail on using the git notes feature in order to have this kind of information: https://stackoverflow.com/a/6799031 . I also found a way to do this in our own CI process as-is since we automatically create tags for each CI build. So those are the two paths I will pursue. Thanks for your help! – Travis Bruce May 14 '18 at 21:02
  • You're welcome. I don't understand why dates matter when bughunting, in my use it's been the commits that matter, so I suspect whatever you're trying to do, there's a better way. Do you know about `git bisect`? – jthill May 14 '18 at 21:07
  • Our CI process kick off twice daily. So whatever commits have made it into the branch in time for the build are what will be tested. So, when the automated tests have failures, we look at the commit log and narrow down by date which commits were committed at the right time range to be potential causes of the failures. I've not heard of git bisect before.. it looks rather involved, but I will look into that a little more. – Travis Bruce May 15 '18 at 15:44
  • 1
    Okay, for that, just keep a ref to the last thing you CI'd, tag it or something, and then to see all the commits in the current history that weren't there last time, ***regardless of commit date or push date***, since that's not what matters, what matters is whether ci's seen them, do e.g. `git log --oneline --graph --decorate last-ci..master` for pretties or `git rev-list last-ci..master` for the straight list. Then `git tag -f last-ci` at the end of your process to get ready for next time. – jthill May 15 '18 at 15:53