Search code examples
gitbashrenamegit-mv

git equivalent for rename


In bash I can do find . -name jndi.properties -exec rename 's/jndi/environment/' {} \; to recursively find all jndi.propertie files and have them renamed to environment.properties.

But git status does not recognize the mv, it shows the deletion and addition separately. How can I do recursive git mv?


Solution

  • Since you're doing an exact match on the name, you don't really need to do a dynamic substitution, do you? If your find supports it (BSD and GNU do, but it's not specified in POSIX) you could use -execdir to execute the command in the directory so you could just do

    find . -name jndi.properties -execdir git mv {} environment.properties \;