20

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?

Tausif Khan
  • 2,228
  • 9
  • 40
  • 51

2 Answers2

27

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.

eckes
  • 64,417
  • 29
  • 168
  • 201
  • 1
    Even if you don't use `git mv`, git should pick up on the fact the files have only moved and not changed. – Benjol Feb 15 '12 at 12:55
  • @Benjol: yes, of course you're right. Just wanted to give the information to OP that there's a built in command for his use case. Updating answer. Thanks. – eckes Feb 15 '12 at 13:07
  • Note that history will be accessible across the change with "git log --follow", but this only works for individual files. – yoyo Jul 09 '14 at 03:41
4

Move your code manually. Then,

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

Done.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141