I am trying to transfer files from one local git repository to another local git repository for another project while saving history from the original repository. So far I have this, which works fine if the file has never been moved or renamed to the original repo:
( cd $SOURCE_REPOSITORY_DIRECTORY && git format-patch -B -M --stdout --root $SOURCE_FILENAME) | git am --committer-date-is-author-date
This happens because the directory structures of the two repositories are the same. If they were different, I would have to create patch files and correct the directory names using sedor something like that.
In any case, it all swells until I hit the file that was renamed. Despite the fact that I specify -B -M(and get the same results with -B -M -C --find-copies-harder), I do not get the fix until the move, although the file was cleared (similarity index 100%).
This is especially strange since it git log --followshows all the commits and git log --follow -pprovides all the differences. Except that he provides them in the reverse order, so I cannot feed them in git am.
Notice that the git log --follow -p filenamefollowing “patch” is displayed to display the rename:
diff
similarity index 100%
rename from old_dir_name/dir1/dir2/filename
rename to new_dir_name/dir0/dir1/dir2/filename
, git log git am, , , . git log --reverse --follow -p filename , .
, git format-patch, , / ? , git log -p , git am, ?
git 1.8.4.3.