Rename file and move to different directory using Git and maintain their history

31 Views Asked by At

I would like to move a file from one folder to another. File currently resides in /dist/somefile.js, I would rename and move to a different location into a new folder /src/my-newfolder/index.js.

I understand when using the mv command, git is deleting the file and recreating it in its new location. The problem is I lose all my commit history.

I've seen many post on stack saying to use git log --follow ./path/to/file but not how it should be used.

should I be doing

git mv /dist/somefile.js /src/my-newfolder/index.js

git log --follow /src/my-newfolder/index.js

I have spent best part of this afternoon looking at this and, there doesn't seem to be a straight forward answer to achieving to what one would think should be an easy thing to do!

thank you.

0

There are 0 best solutions below