Reputation: 333
I'm rather new to git and opened a pull request on github on a project containing some changes I did in my fork. Now I need to revert a few changes on single lines of a single file in an earlier commit.
+-------+ +------+ +------+ +------+
|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 |
+----------------------------+
Whats the easiest way to revert changes made to a single lines of an already commited change?
I'm also trying to preserve modification stamps of other people shown by git blame.
//edit:
I tested the following an it does not preserve the original modification stamp:
foobar.sh contains lines commited by other people, I added new ones and changed existing ones, I need to revert changes made to single lines that I made changes to.
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
Upvotes: 1
Views: 1590
Reputation: 1328982
Simply make a new commit which records the removal of those lines.
You can push that commit on the PR branch: it will be part of your pull request.
Upvotes: 1