Renaming Git Files With Emacs Dired

Álvaro Ramírez has a really handy tip for renaming files under version control with wdired. If you don’t already know about wdired, stop whatever you’re doing and find out about it right now. It’s really magical. The TL;DR is that you can set a dired buffer to be editable and any changes you make—typically to the file names—will be reflected in the actual files. Mickey, over at Mastering Emacs, has a nice introduction.

Ramírez really likes being able to change file names with wdired but was unhappy that those changes weren’t reflected in git in a convenient way. Naturally he set out to remedy the situation. As he discovered, he needn’t have bothered. Wdired already has that handled: you just need to set dired-vc-rename-file non nil. Once you do that, git will show the files as renamed and ask you to commit the changes.

On the one hand, this is a small thing but Emacs, of course, makes it easy to do the right thing so even if your files are under version control—not just git—you can rename them and be sure that dired will inform your version control system of the changes. It makes wdired seem even more magical.

This entry was posted in General and tagged . Bookmark the permalink.