Scott Keck-Warren
Scott Keck-Warren

Reputation: 1952

Determine at which commit a file entered the master branch in git

I'm experimenting with using Git as a CMS for a website because it tracks author information, revisions, and when it was added to the repository. The problem I'm having is that we want to use branches to track future/not-published content while it's being worked on by several people. I can't find a sure fire way to determine when an article/file gets added to the master branch so that date can be used as the "published" date instead of the date it was originally added.

Any ideas on how this could be done?

Upvotes: 3

Views: 164

Answers (1)

vergenzt
vergenzt

Reputation: 10427

$ git log master            \
     --first-parent         \  # stay on this branch
     --diff-filter=A        \  # only check for when the file was added
      -m                    \  # ...but treat merging the file as 'adding' it
     --format="%h %cd %s"   \  # output the abbreviated hash, date, and subject
   <file>

Upvotes: 3

Related Questions