Reputation: 20182
I'm trying to track down who removed some code on a particular file. I don't know when it was but certainly within the past month.
Is there a way to list history of code changes and details on a specific file via a git command?
Update
this didn't work
git log -p --follow -- src/app/company/index.js
Update
tried this
git blame src/app/company/index.js
fatal: no such path 'src/app/company/index.js' in HEAD
Update
ugh, company is capital C...that's what the problem was.
Upvotes: 2
Views: 1466
Reputation: 124646
You can use git log -- path/to/file
to see the commits that modified the file.
It's especially convenient together with the -p
flag,
to include the diff (patch) that affected the file.
If you want to track the history of a file through renames,
then also add --follow
.
git log -p --follow -- path/to/file
Upvotes: 2
Reputation: 1941
You can, but it might be worth using git blame for this, it shows who made the last edit to each line in the file.
Useage is like this
git blame examplefile
Upvotes: 1
Reputation: 39818
git log
accepts file names. If the file doesn’t exist in the current commit, you have to use --
before the name to avoid interpreting it as a revision name.
Upvotes: 0