I'm trying to move my entire repo root into a sub-directory, for everything except one file.
For example, I have something like:
root
-Folder1
-Folder2
-.gitattributes
And for all commits and history, I want
root
-ProjectA
--Folder1
--Folder2
-.gitattributes
i.e., I want to move everything except .gitattributes to a subdirectory. If I use
git filter-repo --to-subdirectory-filter ProjectA/
everything gets moved. I can't find the strategy for moving everything except a single file.
How do I keep the file where it is? Or how do I move just that file back up to the root with another command?
If you can, you would list all elements except .gitattributes
, and rename them in one command, using path renaming:
git filter-repo --path-rename Folder1:ProjectA/Folder1 \
--path-rename Folder2:ProjectA/Folder2 \
...
The OP House suggests in the comments the more sensible approach:
.gitattributes
back with --path-rename 'ProjectA/.gitattributes:.gitattributes'
[Note the single quotes around the parameter value - this avoids the bug/issue with filenames starting with '.']
I would do each step in a separately cloned repository, to make sure I can go back to the original one if it fails.
The second step would be done in a clone of the repository from the first step.