开发者

Permanently merge a git repo to a main repo, keeping history

We have a main repo Core where we maintain libraries we use in many projects.

I was developing a library in a separate repo Error开发者_StackOverflow中文版Handling, that I now want to permanently merge to Core, while keeping the commit history.

Is this possible?


As commented, the subtree merge described in "How to import existing GIT repository into another?", based on GitHub article "Working with subtree merge", is a bit more complete than the basic subtree merge presented in the Git Book (mainly the git merge -s ours step).

git remote add errorHandlingRepo server:errorHandling.git
git fetch errorHandlingRepo 
git merge -s ours --no-commit errorHandlingRepo /master
git read-tree --prefix=errorHandling/ -u errorHandlingRepo/master
git commit -m "Imported errorHandling as a subtree."

You can track upstream changes like so:

 git pull -s subtree errorHandlingRepo master
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜