I 'renamed' a file manually by deleting the old one and adding another with the new name. How do I undo this in the commit history and use git mv instead?I need to rebase my feature branch to the updated parent where the old file name is still being used. I don't want to lose the changes from both the old-name file and new-name file.
$ git commit -m "Rename file" # Commits the tracked changes and prepares them to be pushed to a remote repository. # To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again. Push the changes in your local repository to GitHub.com.
Git keeps track of changes to files in the working directory of a repository by their name. When you move or rename a file, Git doesn't see that a file was moved; it sees that there's a file with a new filename, and the file with the old filename was deleted (even if the contents remain the same).
emiller/git-mv-with-history. git utility to move/rename file or folder and retain history with it. # git-mv-with-history -- move/rename file or folder, with history. # Git has a rename command git mv, but that is just for convenience.
git mv
does the exact same thing as what you did.
When scanning the history, it then tries to spot "renaming" actions by comparing contents, and saying "hmm ... if those two files have 85% content identical, I'll say it's a renaming"
Use git rebase -m
to tell git to look more carefully for renaming.
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