How to move a local git repository to the root folder and preserve history? -


i have local git repository inside project. have decided code needs in project want 1 git repository.

current directory structure:

solution->  - project1    - .git  - project2 

desired directory structure:

solution->  - .git (tracks both projects)  - project1  - project2 

how move .git root folder (solution) can begin watch both project1 , project2 without losing track of modifications/commits?

note: don't care preserving history of files going moved project2 folder.

note: not duplicate (this question) because i'm not moving git repository , whole contents. want move git repository root folder.

the git add -u solution

most elegant, needs 6 commands.

cd solution/ #dot means "move here" mv project1/.git .  #make git add deleted files git add -u  #make recognize them moved git add project1/ 

now git status should show "renamed..."

git commit -m'moved subfolder' 

now check unwanted files , update .gitignore

#add project2: git add --all git commit -m'added project2' 

the subfolder solution

  1. in solution/project1/ create subfolder same name: solution/project1/project1/.
  2. move other contents (except .git/, .gitignore, .gitconfig , new subfolder) of solution/project1/ solution/project1/project1/
  3. cd polution/project1, git add --all, git commit -m'moved subfolder
  4. move contents of solution/project1 solution. project files in solution/project1/ , .git , git-files in solution/
  5. cd solution/, git status. watch unwanted files. add them .gitignore
  6. git add --all, git commit -m'added project2'

the git mv solution

cd solution/project1/ mkdir project1/  #now move files git mv git mv foo.txt project1/ git mv bar.js project1/ git mv fizz/ project1/ ....  git commit -m'moved files subfolder' cd ../ 

now move files solution/project1/ solution. done mv command, don't catch exact syntax.

# should work git status # fix .gitignore if necessary git add --all git commit -m'added project2' 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -