How to split every commit by file?

前端 未结 2 1713
北海茫月
北海茫月 2021-01-06 03:52

I know how to manually split a commit using git rebase -i, but how can I automatically split every commit in a branch by file?

For instance, commit

2条回答
  •  耶瑟儿~
    2021-01-06 04:29

    For every commit, you would need

    • first to list all files in that commit

      git diff-tree --no-commit-id --name-only -r 
      
    • then for each file, extract that file

      git show :/path/within/repo/to/file
      

    Do that in a working tree of a dedicated branch, and for every file extracted, add and commit.

    Then you can reset your current branch by that new one built commit-file by commit-file.

提交回复
热议问题