Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you move multiple files in git?

Tags:

git

I try:

git mv a.py b.py src/

and get

fatal: multiple sources for the same target, source=b.py, destination=src/b.py

Using the -n flag, like so git mv -n a.py b.py src/ gives me:

Checking rename of 'a.py' to 'src/b.py' Checking rename of 'b.py' to 'src/b.py' fatal: multiple sources for the same target, source=b.py, destination=src/b.py 

Am I doing something really stupid? I'm using git version 1.6.6.1

like image 825
pseudosudo Avatar asked Feb 06 '10 10:02

pseudosudo


People also ask

How do I move multiple documents?

To do this, click and hold your left mouse button on the top-left portion of where you want to start highlighting. Next, drag the box until the last file or folder is highlighted. Once the files are selected, they can be copied, cut, or dragged to another window to move them.

How do I move multiple files to a folder?

Right-click the file or folder you want, and from the menu that displays click Move or Copy. The Move or Copy window opens. Scroll down if necessary to find the destination folder you want. If you need to, click on any folder you see to access its subfolders.


2 Answers

I use bash loop:

for FILE in src/*.h; do git mv $FILE include/; done
like image 160
Anna B Avatar answered Oct 05 '22 17:10

Anna B


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.

like image 27
CB Bailey Avatar answered Oct 05 '22 17:10

CB Bailey