git - Join old and new repo, created by copying files (not cloning), preserving commit history -


to simplify things have following structure in git old_repo "subpath":

subpath/old_commit_1 subpath/old_commit_2 subpath/old_commit_latest 

i decided move new_repo , copied latest version of "subpath" (from old_commit_latest) without commit history.

so new_repo has "subpath" , bunch of new commits made it:

subpath/new_commit_subpath_added # added subpath here subpath/new_commit_1 subpath/new_commit_2 subpath/new_commit_latest 

now need migrate history old_repo new_repo following tree in new_repo:

subpath/old_commit_1 subpath/old_commit_2 subpath/old_commit_latest subpath/new_commit_1 subpath/new_commit_2 subpath/new_commit_latest 

how do that?

i need master branch, have lots of files there in same situation. , subpath , filenames in old_repo matches ones in new_repo.

i guess need create patches subpaths in old_repo, rollback first commit each subpath in new_repo, remove first commit, apply patches , rebase new commits on it. not sure how all. appreciate help.

preparations.

you should have both new , old versions available valid repositories. old version should better on local machine, new can on local or remote (say, github).

it's idea have backups of both repos , projects.

i assume last commit of old version first commit of new. if that's not so:

  1. reset newer version it's first commit.
  2. delete files in older version project folder except .git, including .gitignore , other git settings.
  3. copy files newer older version project folder.
  4. save changes new commit on old/master.

joining repositories

# go old repo folder cd path/to/old # add new repo remote git add remote newrepo path/to/new/.git  #check it's added git remote show newrepo  #fetch data new git fetch newrepo  #create branch "new", tracking git checkout -b new newrepo/master  #merge changes old master git checkout master git merge newrepo  #an editor open merge commit message. if you've done preparations, there should no merge conflicts. #this should show complete history git log --oneline 

now have joint history , latest commits in old project directory.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -