changing the git structure

為{幸葍}努か 提交于 2019-11-29 16:55:19

问题


I want to somehow change the git directory structure. Currently the architecture is like

VL(repo)    
    .git (hidden)    
     code files    
     ......    
     .....

I want it like

html(repo)
    .git   
     VL
       code files
       ......
       ......

I had a solution to archive the current repo and then create the new repo with above structure. But the bad thing about this approach is that it removes all previous history. is there any better solution?


回答1:


Changing the name of the root folder from VL to html shall be no problem since git only works on the directories below that level.

So, what's left is introducing the folder VL below the html folder and move all code files there:

mkdir VL
git mv <all your code> VL
git commit -m "moved all my code under VL"

Using git mv you tell git that you moved things, so it could still keep track of the history.


Edit:
As Benjol notes in his comment, using git mv is not neccessary. You could achieve the same by copying <all your code> to VL, then do

  • git add VL
  • git rm <all your code>
  • git commit -m "moved all my code under VL

git is smart enough to recognize the movement.




回答2:


Move your code manually. Then,

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

Done.



来源:https://stackoverflow.com/questions/9293089/changing-the-git-structure

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