0

My question is a simplification of How can I rewrite history so that all files, except the ones I already moved, are in a subdirectory?

I created a repo and committed a project in my IDE. Now all the repo's root maps to the project root and all the files are in the root. How can I move the project into its own subdirectory in order to accomodate additional projects in the same repo, and also rewrite history to look as if everything had been done correctly to begin with?

Community
  • 1
  • 1
Alex R
  • 11,364
  • 15
  • 100
  • 180

1 Answers1

1

This worked for me

git filter-branch --tree-filter 'mkdir NEW_FOLDER; git ls-tree --name-only $GIT_COMMIT | xargs -I files mv files NEW_FOLDER'

Where NEW_FOLDER is the new target subdirectory.

Alex R
  • 11,364
  • 15
  • 100
  • 180