Git Merge two defferent repo and keep both repo history

example:explode repo:repo_abc's branch:develop_abc to new repo:repo_bcd:develop_bcd

#new repo:repo_bcd

$ git clone -b develop_bcd gitolite@git.tw:repo_bcd repo_bcd
$ cd repo_bcd/


#add source(remote repo:repo_abc)

$ git remote add repo_abc gitolite@git.tw:repo_abc.git


#check remote repo

$ git remote -v
repo_abc  gitolite@git.tw:repo_abc.git (fetch)
repo_abc  gitolite@git.tw:repo_abc.git (push)
origin  gitolite@git.tw:repo_bcd (fetch)
origin  gitolite@git.tw:repo_bcd (push)



#get repo:repo_abc's content

$ git fetch repo_abc


#merge source

$ git merge repo_abc/develop_abc
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.



#reslove conflict

$ vim .gitignore
$ git add .gitignore
$ git ci -m 'merge repo_abc'
$ git merge repo_abc/develop_abc

#merge two repo finished, remove remote repo:repo_abc

$ git remote rm repo_abc


#check git history

$ git log --stat


#finally push all changes at repo:repo_bcd

$ git push origin develop_bcd


#free up your disk space

$ cd ../
$ rm -rf repo_bcd
$ git clone -b develop_bcd gitolite@git.tw:repo_bcd repo_bcd 

留言