1

Objective: Want to move files (multiple files) from 1 directory to another directory in a project.

For example, consider the below folder structure:

Project/TRUNK/

so the files like abc.java, xyz.java and Hello.java are in the directory:

Project/abc.java
Project/xyz.java
Project/Hello.java

Practically there are 100 files present in the Project directory. Want to move the files to the TRUNK directory.

I tried to use:

cd Project
git mv abc.java TRUNK

but that moves files one by one. Any suggestion on a git command where the files can be moved at once, will be very helpful.

Anthony Sottile
  • 49,611
  • 12
  • 110
  • 158
Pratim Singha
  • 495
  • 1
  • 8
  • 27

2 Answers2

2

Git doesn't track file copy/move/rename operations so you can move files any way you want, for example with your preferred filemanager, then update index with git add -A . and commit.

phd
  • 69,888
  • 11
  • 97
  • 133
1

As you’ve discovered, you can use the git mv command to move files. To move multiple files at the same time, you can combine this with a glob (shell feature that expands a special pattern to multiple filenames), e.g., to move all files in the current directory whose name ends with .java run

git mv *.java TRUNK

For more information on how to use shell glob patterns to match specific files see the following resources:

Anthony Geoghegan
  • 10,874
  • 5
  • 46
  • 55