Combining multiple git repositories

后端 未结 13 1430
眼角桃花
眼角桃花 2020-11-22 15:34

Let\'s say I\'ve got a setup that look something like

phd/code/
phd/figures/
phd/thesis/

For historical reasons, these all have their own g

13条回答
  •  青春惊慌失措
    2020-11-22 16:15

    Perhaps, simply (similarly to the previous answer, but using simpler commands) making in each of the separate old repositories a commit that moves the content into a suitably named subdir, e.g.:

    $ cd phd/code
    $ mkdir code
    # This won't work literally, because * would also match the new code/ subdir, but you understand what I mean:
    $ git mv * code/
    $ git commit -m "preparing the code directory for migration"
    

    and then merging the three separate repos into one new, by doing smth like:

    $ cd ../..
    $ mkdir phd.all
    $ cd phd.all
    $ git init
    $ git pull ../phd/code
    ...
    

    Then you'll save your histories, but will go on with a single repo.

提交回复
热议问题