Change case in filenames with Git

Over the weekend we had a pull request made for one of the SublimeText organisation plugins which contained a couple of commits that were done so that the read me file would change from readme.md to README.md - it was like this:

  1. Renamed readme.md to readme-old.md
  2. Renamed readme-old.md to README.md.

Whilst there is nothing wrong with that, these commits can actually be compressed into one.

If you try to just run git mv readme.md README.md Git will throw a lovely error.

fatal: destination exists, source=README.md, destination=readme.md  

We can actually override this behaviour by adding the --force flag. Warning: Always watch out when you force or change default behaviour like this. Don't do anything crazy.

So now git mv --force readme.md README.md works perfectly.

Whilst technically yes, you could squish the commits you're rewriting history. Never rewrite history.


comments powered by Disqus