After much searching, I have not found a satisfactory method that is easy to use to view the complete history of a moved file in Git and more importantly in Gitk. Using git log --follow [filePath]
and even gitk --follow [filePath]
gives you the commits that the file was involved in but will not show you the actual change history of the file before the move. I have thus come up with a crude but simple workaround solution.
gitk
on the file that has been moved: gitk [newFilePath]
. Copy the SHA1 ID of the first commit, this should be the commit where the file has been moved.gitk
on the copied SHA1 ID: gitk [SHA1ID]
. The latest commit should be when the move has happened. Find the moved file and copy the old path.gitk
on the SHA1 ID we just copied and the old file path: gitk [SHA1ID] -- [oldFilePath]
This process will allow you to view the history of the file before the move. If there have been multiple moves the above process can be repeated.
If there are any better solutions to this problem, especially if there is a way to combine these steps to display the full history with the moves, it would be highly appreciated.
Using git log --follow -p bar will show the file's entire history, including any changes to the file when it was known as foo .
Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.
The git log command displays all of the commits in a repository's history. By default, the command displays each commit's: Secure Hash Algorithm (SHA) author.
To pull up a list of your commits and their associated hashes, you can run the git log command. To checkout a previous commit, you will use the Git checkout command followed by the commit hash you retrieved from your Git log.
If you want to see the changes that was made in each commit even the file has been renamed, you can use the option -p
of git log
:
git log -p --follow [file/with/path]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With