First of all, I had a look at this question which is exactly the same what I am addressing here. But the problem is the solution given in the question, does not work for me.
The solution given is this:
git filter-branch --tree-filter "cd x; mkdir -p p/q; mv [files & sub-dirs] p/q" HEAD
to move files & subdirs under x
to x/p/q
.
This is exactly what I want. But this does not work when I tried.
My directory structure is:
mdwtest |-src | |-main | | |-java | | | |-a.txt | |-test | | |-java
I tried this command from cmd.exe
in mdwtest
directory which is my git local repository. I ran cmd.exe
as administrator.
git filter-branch --tree-filter "cd D:/gittraining/mdwtest/src; mv main/java/ /test/java/" HEAD
But it gave the below output in cmd.exe
console:
D:\gittraining\mdwtest>git filter-branch --tree-filter "cd
D:/gittraining/mdwtest/src; mv main/java/ /test/java/" HEAD Rewrite
09a1198eeb1bf26a1245ea00cae38f22e91fd708 (1/15)mv: cannot move
`main/java/' to `/test/java' tree filter failed: cd
D:/gittraining/mdwtest/src; mv main/java/ /test/java/ rm: cannot
remove `/d/gittraining/mdwtest/.git-rewrite/revs': Permission denied
rm: cannot remove directory `/d/gittraining/mdwtest/.git-rewrite':
Directory not empty
What I can get out of this is that it has some problem over moving main/java
to test/java
and I don't have any clue on what could have prevented it from doing so.
Actually I expected src/main/java/a.txt
file to have moved to src/test/java
along with history.
While the solution seems to have worked for many people, looks like something is going wrong in my case.
Could you help explaining me on what am I missing here ?