How do I combine two Git repositories, one a snapshot of the other with current history? -


i need inverse of this question.

so year ago split our git repository off copying current state of both branches new repository. make simple:

<== 2015 dec              1 jan                    2016 jan ==> past history, till svn    new repo first commit    commits present 

we using subtrees turn each of projects in repository own git repository, not want long missing 5 years of our commit history in our central repository. here steps i've tried far:

cd projectfull/ git reset --hard # project in branch git checkout master # go master before trying rebase git remote add projectsplit ../projectsplit # new repository in directory git fetch projectsplit # fetch new repository git cherry-pick <initial commit hash> --strategy-option theirs git pull --rebase -s recursive -x theirs origin master 

my idea cherry-pick new repo's initial commit , rebase off of commit, fails. commands i've listed above not error out, delete of history of old repository.

here's truncated log of git rebase:

$ git rebase origin dev first, rewinding head replay work on top of it... applying: merge branch 'dev' of <repo> dev using index info reconstruct base tree... <stdin>:298480: trailing whitespace.  <stdin>:298553: trailing whitespace.  <stdin>:298559: trailing whitespace.  <stdin>:298565: trailing whitespace.  <stdin>:298571: trailing whitespace.  warning: squelched 1751272 whitespace errors warning: 1751277 lines add whitespace errors. falling patching base , 3-way merge...  conflict (add/add): merge conflict in <file> auto-merging <file> conflict (add/add): merge conflict in <file> auto-merging <file> conflict (add/add): merge conflict in <file> auto-merging <file> conflict (add/add): merge conflict in <file> auto-merging <file> conflict (add/add): merge conflict in <file> auto-merging <file> <same>  failed merge in changes. patch failed @ 0001 merge branch 'dev' of <repo> dev copy of patch failed found in:    projectfull/.git/rebase-apply/patch  when have resolved problem, run "git rebase --continue". if prefer skip patch, run "git rebase --skip" instead. check out original branch , stop rebasing, run "git rebase --abort". 

the script in answer failed halfway through old repo's patches.

this answer works dissimilar repositories.

your mileage may vary , may have misunderstood question , intent, i'll propose options short summary:

consider stitching repos

perl cpan has git-stitch-repo, nice module streamlines git fast-export git fast-import.

should linearize history.

subdir option

have 2 dirs instead of one. or multiple dirs.

you following procedure already. abandon final cherry-picking question , have old repo directory along current one.

least troublesome, glues repos together. doesn't try linearizing history.

git subtree merge

merge subtree git command, easier use both subtrees , submodules (and less administer-heavy).

you may need use --follow when looking @ git log individual files (after merge).

reexamine why need it

are helpful? if feed old git log elk, indexed search fit colleagues (and yourself) better? possibility of setting dashboards in kibana? or if set git instaweb on machine old repo, folks can browse through web, perhaps meet demands?

consider git merge-repos

never tried, can't recommend, it's apparently such occasion , written when git-stitch-repo young. may worth checking out.

with rewrite

there an option history rewrite, git filter-branch. can done bfg well.


Comments