It turns out a git repo I created betters suits as subdirectory, say module x
, of a more general repository. How can I copy the original history (no signed commits) over such that now all the paths have the prefix module x\
?
I could of course simply make moving everything into that subdirectory a new commit, but I'd prefer a solution that makes history look as if the former repo was always in the subdirectory.
I tried git subtree add --prefix="module x" ../module_x master
from a temporary parallel folder with a fresh repository (since otherwise git subtree
complains about the already existing prefix), but end up with
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Working tree has modifications. Cannot add.
This seems to be due to the lack of an initial commit, because if I
touch .gitignore
git add .gitignore
git commit -m"Init"
it works, but I end up with the original history in a separate branch plus a commit of moving, so just the manual solution I mentioned before...