How do you merge two Git repositories?

后端 未结 23 3343
耶瑟儿~
耶瑟儿~ 2020-11-21 05:45

Consider the following scenario:

I have developed a small experimental project A in its own Git repo. It has now matured, and I\'d like A to be part of larger projec

23条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 05:51

    I merge projects slightly manually, which allows me to avoid needing to deal with merge conflicts.

    first, copy in the files from the other project however you want them.

    cp -R myotherproject newdirectory
    git add newdirectory
    

    next pull in the history

    git fetch path_or_url_to_other_repo
    

    tell git to merge in the history of last fetched thing

    echo 'FETCH_HEAD' > .git/MERGE_HEAD
    

    now commit however you normally would commit

    git commit
    

提交回复
热议问题