0

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
  • 61,815
  • 15
  • 148
  • 207
Pratim Singha
  • 569
  • 2
  • 10
  • 33

2 Answers2

3

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
  • 11,533
  • 5
  • 49
  • 56
1

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
  • 82,685
  • 13
  • 120
  • 165