I migrated my svn repository to git, however for some reason there are still trunk folders, which should not be the case. I want to remove these folders without damaging the history line.
This is the git repository I have at the moment:
- My repository
-- Project1
--- trunk
---- src
---- somefile.txt
---- someotherfile.cpp
---- andanotherfile.cpp
and this is what I want to have:
- My repository
-- Project1
--- src
--- somefile.txt
--- someotherfile.cpp
--- andanotherfile.cpp
I got to know that the command filter-branch is used to for this, however I could not find an example which suits my case, apart from this and this, but then even there I felt a bit confused and not sure if I should try or not. Anyone ran into something similar and can confirm that those are the solutions?
Thanks in advance.
Update: So I got to know that the following command is used most of the time to do the deed:
git filter-branch --index-filter \
'git ls-files -s | sed "s-/trunk/-/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
indeed, I checked the sed line and it does tell me that it would remove the trunk and move whatever is inside, to the upper directory. However, the execution gives and error of:
../myrepository/.git-rewrite/t/../index.new': No such file or directory
I don't know why am I getting this error. I looked it up and it seems I need an addition to this command, a number before the HEAD
, like 83df928c..HEAD
. However, I don't know what this is for (I mean, revision number, most likely, but why?) or what is mine. Would appreciate help. Almost got it!