How do you move multiple files in git?

In Windows (PowerShell):

foreach ($file in get-childitem *.py) { git mv $file.name ./src }

I use bash loop:

for FILE in src/*.h; do git mv $FILE include/; done

This has been fixed in the current master branch of git, it's in v1.7.0-rc0 but not in a release build yet.

http://git.kernel.org/?p=git/git.git;a=commit;h=af82559b435aa2a18f38a4f47a93729c8dc543d3

In the mean time the simplest thing to do is to either git mv the files individually or to just use mv and then update the index manually, e.g. with git add -A if you have appropriate .gitignore patterns.

Tags:

Git