git – How do I see which commits change a certain file?

Question:

I implemented a new feature for my program in a Func1.cpp file, in the Func1 branch. Next, I created one more feature — in the Func2.cpp file — but I forgot to create it in a separate Func2 branch . Now I would like to separate a branch for each feature.

For that, I need to know which commits change the Func1.cpp file and which ones change Func2.cpp. So I can rebase --interactive and then separate the branches. I tried git show <SHA1> , but it shows me diff info I don't need.

Question: How can I find out which commits change which files?

Answer:

git log <arquivo>

To make git understand and follow the file even when renamed:

git log --follow <arquivo>
Scroll to Top