Reputation: 35282
I need to move folders up with Git without losing history of Java codes.
Currently:
desktop: ~/projects/github/trunk/myapp
The .git
folder is there in trunk
not in myapp
(due to I just imported this repo)
How to I make the .git
move to my myapp
folder or do a git mv
to move all the files and folder from myapp
to trunk where the .git
directory is.
Either case is fine. I just need to make sure that the history is retained where when we browse history of file in Git we can see it still there.
Upvotes: 1
Views: 320
Reputation: 690
Since the .git
folder is in trunk
, there is no need to mv the .git
folder into my app
, you can simply use:
git rm -rf --cached <file/folder you won't need>
to remove the file/folder, which you don't want to be shown in repository, in trunk
from the index. (this step is not a must-have)
then:
git add --all app/*
to add all the files under app
to the repository, then:
git mv app/* ./
git rm -rf app
to move all of the files/folder from myapp
to trunk
, and remove the empty myapp
folder.
then commit the change:
git commit -m 'Moving the Java codes'
then rename folder trunk
to myapp
:
mv ~/projects/github/trunk/ ~/projects/github/myapp/
Best Regards
Upvotes: 1
Reputation: 272517
I would assume that the following is sufficient:
git mv myapp/* .
git commit -m "Moved stuff"
Upvotes: 0