How to I combine two separate Git repositories?

前端 未结 2 601
慢半拍i
慢半拍i 2020-12-18 16:17

I have cloned a git repo which has my emacs config files in. I would like to add pylookup in a subdirectory. What is the correct way to do this?

Below are the optio

相关标签:
2条回答
  • 2020-12-18 16:36

    If you create a Git submodule:

    $ git submodule add git://github.com/tsgates/pylookup.git pylookup
    $ git submodule init pylookup
    $ git submodule update pylookup
    

    Let's say there are some changes to pylookup and you want to get them:

    $ cd pylookup
    $ git pull origin master
    $ cd ..
    $ git add pylookup
    $ git commit -m "Track new commit of pylookup"
    
    0 讨论(0)
  • 2020-12-18 16:55

    I used subtree merge with a similar problem - http://git-scm.com/book/en/Git-Tools-Subtree-Merging. Something like:

    $ git remote add -f pylookup /path/to/pylookup
    $ git merge -s ours --no-commit pylookup/master
    $ git read-tree --prefix=pylookup/ -u pylookup/master
    $ git ci -m "merging pylookup into pylookup subdirectory"
    

    Good guide here: http://jasonkarns.com/blog/merge-two-git-repositories-into-one

    0 讨论(0)
提交回复
热议问题