How to delete a file, rename another file to the deleted filename in Git

My team has been working on a game that was 16 bits originally. We have since simplified to 10 bits. My understanding of ideal Git strategy would be to create a branch 10Bit, and change the code to 10 bits without altering the filenames; however, my teammate made copies of several files, with 10Bit appended to the filename, without deleting the old file. This was several commits ago, and now our filesystem looks like this:    # <--Old 16-bit code, not used in 10-bit
Master_Constraints.xdc # <-- same
Master_Constraints10Bit.xdc    #    <-- same

We want to get back to the original names, without the 10Bit part. But if I do

git rm
git mv

git doesn't see this as a simple file rename. Instead, git status or a git diff shows that was deleted, and was changed significantly. This isn't what happened, though; a git diff should show that was deleted, and that was renamed to

Likewise for all the other files.

What's a good way to go about this change?

1 answer

  • answered 2018-12-05 20:23 apapillon

    You must remove, commit changes and finaly rename to

    git rm
    git commit -m "Remove old files"
    git mv
    git commit -m "Rename files"