Spyros
Spyros

Reputation: 48606

Change Git Root Folder contents to a Subfolder

i have a git repository that i created some time ago, and i made the mistake of putting all the files of my project in the root git repository path. However, i discovered that i want to version control some more elements that do not really belong to the root folder.

My current git is like :

git_repos/file1
git_repos/file2
...

I would like to convert that to :

git_repos/demo/file1
git_repos/demo/file2
git_repos/other_folder
git_repos/other_folder/file

You get the idea. I know i may be able to do it by moving files, but something tells me that there is probably a better way. Is there ? :)

Upvotes: 3

Views: 2012

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 992757

The git mv command is what you want to use. You can move more than one file at once by ensuring that the final destination name is a directory. For example:

git mv file* demo/

Don't forget to commit the result when you're done, of course.

Upvotes: 3

Related Questions