4. cherry-pick

优质
小牛编辑
115浏览
2023-12-01

为了节省时间,这个教程使用现有的历史记录作为本地数据库。

从这里下载

我们进入stepup-tutorial/tutorial4目录。本地端历史记录的状态如下图显示。仅把在其他分支执行的「添加commit的讲解」的修改导入到master分支。

数据库的历史记录

把修改移动到master分支后,用cherry-pick 取出「添加commit的讲解」提交,然后将其添加到master。(文档里的提交"99daed2"和下载到数据库里的提交有可能不相同。在下载的数据库里执行git log,确认是正确的提交之后再使用。)

$ git checkout master
Switched to branch 'master'
$ git cherry-pick 99daed2
error: could not apply 99daed2... commit
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

如果发生冲突,就打开sample.txt,修改冲突的部分之后再提交。

$ git add sample.txt
$ git commit