问题
I have a subdirectory named "www" that is a repo:
site
|-- www/
| |-- .git/
| |-- index.html
|-- design/
| |-- images.jpg
I'd like to change the repo to the parent directory so that the repo structure mirrors the original file structure as follows:
site
|-- .git/
|-- www/
| |-- index.html
|-- design/
| |-- images.jpg
Can this be done? Are there implications with then pushing the changes up to Gitlab?
回答1:
- Create a
www
directory in your repo. git mv
the HTML files to that directory. Optionally commit this step.mv
the design directory into your repo, andgit add .
- Commit.
- Rename/move your whole repo.
回答2:
The following instructions will work.
cd www
mv .git ../
git add www
git commit -a -m "Change root directory of project"
git add design/*
git commit -m "Start tracking design folder"
This will preserve your history.
来源:https://stackoverflow.com/questions/32082366/move-git-repo-to-parent-directory