Moving a git repository down a hierarchy level

≯℡__Kan透↙ 提交于 2019-12-04 19:18:04

问题


I was searching for hours now but couldn't find a satisfying answere even though it appears to be simple noobish question. What I basically want to accomplish is to move my .git directory which currently resides besides my project folder down into the project folder. Optimally this shouldn't alter the repository history at all although I don't know whether this is actually possible. The reason I want to do this a somewhat IDE/project-type related problem I can solve this way.

I appreciate any help, thanks.


回答1:


Sure just move it, then do a

git add -A
git commit -m "moved project"

in the new root. It won't be a big change in terms of data. It's just going to change the current commit's tree. All objects already exist.




回答2:


If you want your git repository to be changed so that it always looked like your files were located in the new path, you could re-write history similar to this

Otherwise, Adam's answer is what you want.

EDIT: Note that you should NOT use this if you or anyone else may be already using this repository as a submodule or a subtree anywhere.



来源:https://stackoverflow.com/questions/13521782/moving-a-git-repository-down-a-hierarchy-level

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