Reputation: 3931
In Git, it is possible to have e.g. a topic branch which contains one or more commits that are dated when the commit is created. Some time later, those commits can be added to a different branch, generally via merge or rebase.
Normally, git log
will show a list of commits ordered by the date & time the commit was created. Is it possible to view this list based on the date & time the commit was added to the current branch? More specifically, I'm looking to write a script that will return to me a list of commits added to the branch in the last week, regardless of when the commit was created.
A simple example:
Suppose a commit is created in the branch topic
on July 22nd. A few days later, on July 25th, the topic
branch is merged into master
. If I run my hypothetical list-commits
script, asking for all commits which were added on or after July 25th, I would want the aforementioned commit to show up, since it was merged on July 25th, even though it was created on July 22nd.
One extra note is that, in my typical Git workflow, I only use fast-forward commits, so when I merge one branch into another, no merge commit is generated. I need a way to retrieve this information without relying on merge commits.
Upvotes: 3
Views: 164
Reputation: 22717
You could always write a script that will merge for you, adding an additional commit that describes what was merged. This approach would give you quite a bit of freedom, since you could modify the master either before or after doing the merge, choosing the arrangement that gives you the best results.
Edit
git reflog
might give you the information you're missing. With a bit of work,
Upvotes: 1
Reputation: 246
You would have to reverse any merges in the branch to determine when the commits were added to the branch. Other than that, only the time of the commit is stored.
Basically, find any merge commits and determine the order of events via those.
Upvotes: 1