Clayton
Clayton

Reputation: 2007

When was a file added to a branch in Git?

Is there a simple way to find out when (in which commit or merge) a file was added to a branch? Specially, from an experimental feature branch to master.

Upvotes: 0

Views: 207

Answers (2)

qqx
qqx

Reputation: 19475

You can use

git log --first-parent -- <file>

to list the commits along the main branch which have modified that file. The last one listed would be the commit where the file was introduced to the main branch.

This does depend on merges being done while on the main (e.g. master) branch to pull in change from the other branches, and not the other way around.

Upvotes: 0

twalberg
twalberg

Reputation: 62379

git log <branch> -- <file> should do the trick...

Upvotes: 1

Related Questions