Steven Steven - 11 months ago 40
Git Question

Not expected log after renaming a file in git

I renamed a file in a git repository with:

git mv

git status
gave me that the changes need to be committed are renaming the file.(I didn't write
git add
I committed then pushed to GitHub and the file named was changed successfully.
But when I opened the file on GitHub and saw it's history it was containing only the last commit not all of its commits.

Can someone please explain to me what happened?

Answer Source

Git doesn't move history of edits in a file when you move. It would create a huge set of problems when doing patching, reverting commits etc. git mv is a shortcut for removing file and adding to list of tracked files.

GitHub doesn't show complete history of files but you can do it manually with git log --follow, it should show changes before git mv