如何将具有 10 个提交的单个文件拆分为具有单个提交的 10 个文件?

How to split a single file with 10 commits into 10 files with single commit?

我有一个包含多个提交的文件,我想将此文件拆分为多个文件,每个文件都包含一个提交。

例如 :
A.cpp 有 git 历史:
commit message 1。掉蛋问题
commit message 2。反转二叉树

我想将两个文件命名为

1. Egg dropping Problem.cpp 仅包含commit 1的数据。
2. Invert a binary tree.cpp 仅包含commit 2的数据。

git format-patch

format-patch creates one patch file for each commit you specify.

# x is the number of commits you need
# git format-patch HEAD~X (or the next one:)
`git format-patch ~<first-sha1>`