You must use “git mv” when you change a file name
When you changed a file name, but it was not reflected to git, you should read this article.
That accident happened
When I was coding, the accident happened. I changed a file name through editor and pushed it, but WebPacker in other colleague’s PC didn’t recognise the file name changed though I pushed the change to remote repository.
The cause was
I was using React, so I thought the cause was WebPacker firstly. WebPacker didn’t recognise the change? No. Of course, it was possible, but There was more possible point in this case. That was “the file name in “changed files” of GitHub was previous version”. I looked it up online, and found a comment. “If you change a file name through your editor, the change is not reflected to Git. You must use git command.”
The solution was
I didn’t know that. I executed the command ‘git ls-files’. The file name was previous version. GitHub didn’t notice the change. I found the solution too. It was “git mv” command. You can change the file name and git recognise it.
git mv /to/your/previous/ver/file /to/your/latest/ver/file
Wrap up
It worked well in the end. Basically, when we update files under control of git, we should use git command. Never update it directly through your editor!