(E)Git history after renaming or moving a file

When renaming/moving a file, git log /path/to/file will only show the commits history from that renaming/moving until now. To follow the commits until the first one and display them in the history you will need to do a

git log --follow /path/to/file

All the commits will be shown in the history. But note that this will work only for a single file.

If you’re using Egit in Eclipse, you can do the same by checking the box Follow Renames in Preferences -> Team -> Git -> History

PS: If you want to move a file in a git repository, you can consider using git mv oldpath newpath which is a shorthand for

mv oldpath newpath
git add newpath
git rm oldpath

More informations and options for git log.

Leave a Reply