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
- in
solution/project1/create subfolder same name:solution/project1/project1/. - move other contents (except
.git/,.gitignore,.gitconfig, new subfolder) ofsolution/project1/solution/project1/project1/ cd polution/project1,git add --all,git commit -m'moved subfolder- move contents of
solution/project1solution. project files insolution/project1/,.git, git-files insolution/ cd solution/,git status. watch unwanted files. add them.gitignoregit 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
Post a Comment