3

I have this big repository containing different modules, which should have been broken down in different repositories, one for each module. Sometimes I created a branch, say featbranch, in the repo to work on a specific module, but featbranch had no meaning at all for other modules. You can imagine the mess this could cause...

Anyway, my question is: how do I get the latest commit that changed a specific file, and possibly which branch such commit belongs to? By "latest", I just mean the one with highest timestamp, as I understand that commits from different branches would likely not have any precedence relation.

Eduardo Bezerra
  • 1,762
  • 1
  • 16
  • 30

1 Answers1

7
git log -n 1 --date-order --all -- <file>

(Note, this might not be the commit with the latest timestamp if someone has made "an older" commit directly on top of a newer commit. This can only happen is someone is lying about the time when they make a commit, though.)

CB Bailey
  • 648,528
  • 94
  • 608
  • 638