Making git format-patch follow renames like git log --follow

后端 未结 3 1893
夕颜
夕颜 2021-01-03 03:15

I am trying to move files from one local git repository to another local git repository for a different project while preserving history fr

3条回答
  •  情话喂你
    2021-01-03 03:47

    I've made some progress, but it's much more manual now.

    • For each file, use log with and without --follow to see which files have been renamed/moved/copied (calling them all "renamed" for simplicity).
    • For files that have been renamed, extract the previous complete path and filename(s) from the log output.
    • Then use format-patch but give all the old names as well as the current name on the command line.

    So now I have something like this:

     git format-patch -B -M -o /tmp/patches --root -- old_dir_name/dir1/dir2/filename new_dir_name/dir0/dir1/dir2/filename
    

    which creates the patches to create the old file, rename it to the new name, and then continue patching the file. Of course the problem there for me is that the old directory doesn't exit in the new repo and the directory level has changed, so there is still some mucking about to do with getting the directory names to work.

    This should be easier....

提交回复
热议问题