add history to git repository or merge git repositories -


everybody understands different "merge git repositories", here case. had tfs repository , have checked out sources @ 1 point in time , made initial git commit. did normal development in git (branching, merging, etc.). problem in new repository not have history in out git repository , fix that. therefore have converted whole tfs repository git repository , need merge converted tfs repository current git repository.

as becomes obvious above description repositories independent git standpoint, logical point of view have 1 commit in common (the commit became initial commit current git repository).

how merge repos without losing history of of them? take converted tfs repo base , cherry pick changes master of current repo, not import branches created in current repo.

edit: previous answer not lead nothing good. git rebase not meant this. however, similar happened on stackoverflow: merging 2 git repositories obtain linear history

you can try procedure:

git init combined cd combined git remote add old url:/to/old git remote add new url:/to/new git remote update 

you have new repo, references both repos. then

git reset --hard old/master 

this make master branch point master branch of old repo. can cherry pick commits master branch of new repo

git cherry-pick <sha-1 of first commit on new repo>..new/master 

we started: master branch ok, other branches in new repo? well, not need old repo anymore,

git remote rm old 

then, have branch named 'branch1' in new repository.

git checkout branch1 git rebase master 

this should change history of branch1 make start master (the combined master, containing history imported repo), , rebasing should happen without conflicts. check history consistent gitk, can force push with

git push -f new master git push -f new branch1 

you have sure history ok before forcing push, since change history upstream (keep backup of both new , old repos recover if needed)


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -