假设我们有2个这样的提交:
commit id: abz
contain files : a, b and z
commit id: xy
contain files : x and y
问题是,是否可以将文件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!