git:在以后的提交时还原合并

时间:2020-01-15 18:08:15

标签: git

我将半熟的功能合并到git树的主主分支中。后来,我在“ master”中做了几次提交,这些提交影响了完全不相关的文件。所有这些都已经被推送到远程了。

现在,我想还原在该半成品功能中所做的更改,但又不丢失以后的提交。我该怎么办?

1 个答案:

答案 0 :(得分:1)

您可以checkout将受半烘焙功能影响的文件合并到提交中。

# find the commit hash with 
git log
# checkout those files to the commit you want
git checkout c5f567 -- file1/to/restore file2/to/restore
# commit to master