git - Merge two repositories (original project and changed project WITHOUT HISTORY) -
i have 2 repositories:
- gephi (big open source project) hosted on github
- project of company based on gephi
7 months ago, when our project started, took snapshot of gephi project on github , save corporate svn => change history loss
now decided move our project git repository , merge changes original project
i have git repository migrated svn git-svn
my files not have change history beyond time when our project started
can map initial state of our repository state of original repository? in other words start aplying our changes original repository specific revision.
update:
today found obstacle. schema first:
red branch original project
<alpha1>
,<alpha2>
commits of plugins main project (unrelated code commited in<e' e'' e'''>
)in
<e'> <e''> <e'''>
added code main project (red) repository<e>
(in each commit cca 1 third of project<e>
)
i have fetched red , blue repositories one. on second schema have desired state. possible this? (for example make <e' e'' e''>
1 commit (<e'>
) , mark commit merged branches <abcd>
, <alpha1 alpha2>
)
thank julien response. seems helpful.
disclaimer: have tested this, , seems works expected (assuming understood correctly, of course). however, there's still lot can go wrong. absolutely try out on separate working copy of project's repository, , make sure examine before pushing anywhere. keep full directory backups of state before did this.
so assume have 2 independent repositories. original project (gephi):
a---b---c---d---e ^ head of gephi
and project, first revision looks identical original project's last revision:
e'---v---w---y---...---z ^ head of project
(possibly branches, doesn't matter here.)
what you'd have (if understood correctly) is:
a---b---c---d---e---v---w---y---...---z
you try following. again, on own, separate working tree, , make sure in order before pushing central repository!
while in directory of own working tree, fetch heads , objects of original gephi repository:
git fetch /path/to/original/gephi
if haven't cloned gephi repository, might specify github url instead of local filesystem path.
this result in following situation in current working tree:
a---b---c---d---e ^ fetch_head e'---v---w---y---...---z ^ head
we haven't changed lot. currently, 2 heads coexist peacefully , independently each other, have access objects both repositories , can try combine them.
we want discard e' (it should identical e), , instead make e parent of project's first commit, v. this, can use git filter-branch
:
git filter-branch -f --parent-filter 'test $git_commit = <v> && echo "-p <e>" || cat'
replace <v>
, <e>
commit hashes of v , e respectively. find out, can git log
examine project's commits and, since we've fetched them, git log fetch_head
examine gephi's commits.
this connect v directly e.
this should work if turns out head (i.e. latest commit) of original gephi repository isn't based project on, meaning there have been new commits in gephi haven't (yet?) taken care of. sure, again substitute <e>
hash of commit have based changes on, not head.
conversely, sure substitute <v>
hash of first change made. maybe repository doesn't contain e' identical e, first commit contains changes toward original. first commit hash <v>
, instead of 1 after it.
to summarize both last paragraphs: above command should work if situation looks like, example, this:
a---b---c---d---e---f---g---h---i ^ ^ fetch_head point project branched off v---w---y---...---z ^ ^ head first change based on e
just make sure use commit hashes make sense in context.
Comments
Post a Comment