Move .git repo to parent directory [duplicate]

烂漫一生 提交于 2020-01-01 23:12:31

问题


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:


  1. Create a www directory in your repo.
  2. git mv the HTML files to that directory. Optionally commit this step.
  3. mv the design directory into your repo, and git add .
  4. Commit.
  5. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!