In a Git repository, on the main
(or master
) branch, I would like to identify the "latest" commit in the topological order, including merge commits, which made any change in a specified directory.
More context:
I have a kind of mono-repo managed on GitHub. Imagine it's like below:
/
|-- file1
|-- file2
|-- subproject1/
| |-- file1-1
| `-- file1-2
|-- subproject2/
| `-- file2-1
`-- subproject3/
`-- file3-1
- Assume it's on GitHub
- Assume any force push is prohibited on the
main
branch (by restricting on GitHub) - Assume the
main
branch can be updated with the latest commit of :- A plain (non-merge) commit by :
- "Rebase and merge" (whose last commit is a plain commit) from a pull request
- "Squash and merge" from a pull request
- A direct fast-forward push (whose last commit is a plain commit) on
main
- A merge commit by :
- "Merge pull request" from a pull request
- "Rebase and merge" (whose last commit is a merge commit) from a pull request
- A direct fast-forward push (whose last commit is a merge commit) on
main
- A plain (non-merge) commit by :
- Under those assumptions, I'd like to identify :
- the "latest" commit (either a plain or merge commit above) that made any change in a specific directory, ex,
subproject1/
, - in the topological order (not author-date nor commit-date)
- from
HEAD
of the currentmain
branch
- the "latest" commit (either a plain or merge commit above) that made any change in a specific directory, ex,
I looked into these questions and answers below, but not very sure...
Does anyone have ideas?