git在提交的单个文件中的单行上还原

git在提交的单个文件中的单行上还原,git,github,Git,Github,我是git新手,在github上打开了一个pull请求,请求的项目中包含了我在fork中所做的一些更改。 现在,我需要在以前的提交中恢复单个文件的单行上的一些更改 +-------+ +------+ +------+ +------+ |pullreq+<--+commit+<--+commit+<--+commit| +-------+ +------+ +--+---+ +------+ ^

我是git新手,在github上打开了一个pull请求,请求的项目中包含了我在fork中所做的一些更改。 现在,我需要在以前的提交中恢复单个文件的单行上的一些更改

+-------+   +------+   +------+   +------+
|pullreq+<--+commit+<--+commit+<--+commit|
+-------+   +------+   +--+---+   +------+
                          ^
            +-------------+--------------+
            |1  some other peoples code  |
     undo-->+2         my changes        |
            |3  some other peoples code  |
     undo-->+4          my changes       |
            |5          my code          |
            +----------------------------+

只需进行一次新的提交,记录删除这些行的情况


您可以在PR分支上推送该提交:这将是您请求的一部分。

根据您的回复,我尝试过(请参见相关编辑),但没有按照我的需要进行操作,因为我试图恢复到一种状态,即最后一次对行进行更改是由其他人进行的。@hub最后一次更改是谁做的并不重要:在您的本地克隆回购中,进行正确的更改(添加/删除或修改行),添加、提交并推送到您的PR分支。“恢复”是一个新的提交(由您完成),它恢复(取消)旧的更改(无论是谁做的更改)
git clone https://github.com/user/somerepo
cd somerepo
git blame -L 10,20 foobar.sh
nano foobar.sh
git add foobar.sh
git commit
git blame -L 10,20 foobar.sh
nano foobar.sh
git add foobar.sh
git commit
git blame -L 10,20 foobar.sh