假设我们有 2 个这样的提交:
commit id: abz
contain files : a, b and z
commit id: xy
contain files : x and y
Run Code Online (Sandbox Code Playgroud)
问题是,是否可以将文件 z 从 abz 移动到 xy,如果可以,那么如何移动?
您可以cherry-pick提交abz文件,然后取消其中的所有更改,然后添加相关内容并提交新更改
以下是可以帮助您执行此操作的一系列命令:
git cherry-pick -n <commit> # get your patch, but don't commit (-n = --no-commit)
git reset # unstage the changes from the cherry-picked commit
git add -p # add the changes you do want
git commit # make the commit!
Run Code Online (Sandbox Code Playgroud)