Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing the git structure

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?

like image 375
Tausif Khan Avatar asked Feb 15 '12 12:02

Tausif Khan


People also ask

What is git structure?

The Git file directory is structured like a tree. It starts with a HEAD that points to the latest commit on the working branch. The HEAD will always show you where you are working from on Git Bash. Imagine you are driving and arrive at a crossroads and point your car in one direction.


2 Answers

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.

like image 195
eckes Avatar answered Oct 02 '22 18:10

eckes


Move your code manually. Then,

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

Done.

like image 36
Adam Dymitruk Avatar answered Oct 02 '22 18:10

Adam Dymitruk