How to combine multiple GIT repositories into a repository
I have three repositories, I want to combine into a respository.
For example:
repository01,url:remote_repository01_url
repository02,url:remote_repository01_url
repository03,url:remote_repository01_url
Step1:Build a new repository.
Step2:Merge new_respository and repository01.
Step3:Move repository01 to new location in new_repository
Final:
I just repeat Step2 and Step3 for other repostories.
For example:
repository01,url:remote_repository01_url
repository02,url:remote_repository01_url
repository03,url:remote_repository01_url
Step1:Build a new repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir new_respository | |
cd new_respository | |
git init | |
echo "combine git" >> README.md | |
git add README.md | |
git commit -m 'initial git repository' |
Step2:Merge new_respository and repository01.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#add remote repository and merge to new_respository | |
git remote add repository01_name remote_repository01_url | |
git fetch repository01_name | |
git checkout -b repository01_name repository01_name/master | |
git checkout master | |
git merge repository01_name | |
# save merged message |
Step3:Move repository01 to new location in new_repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir repository01 | |
git mv * repository01/ | |
# You should move files or directories that do it a object by a command. | |
git commit -m 'move repository01 source' | |
git remote remove repository01 |
Final:
I just repeat Step2 and Step3 for other repostories.
留言
發佈留言