I mistakenly replace all and save lines in my documents that are all tracked by Git. I have done some work before and forgot to commit as a checkpoint before doing that, so reverting is not desirable as it would revert all of my work. I would like to revert only the replace all operation using help from Git.
I know all the lines that I need to revert because they all have the same new line. From GUI tools like SourceTree I can click Discard Hunk one by one, but there are many such location that I would like to discard. All the places I would like to revert has new line that says
m_Sprite: {fileID: 21300164, guid: 791de2a5646d94a15a09bb1d7e79a0e6, type: 3}
But old line is not necessary the same. (In fact there are 2 kinds of old lines that I changed into this same new ones) Are there any scripted way to match the pattern of changed lines so I can selectively revert them all? Thank you.
Using git add -p
interactively to add everything except the hunk I don't want going forward is very tedious, since it ask you one by one but there are so many works to add and at the same time the hunks I don't want are mixed in almost every file. (So I must be very careful on every question git asks) The same goes for git checkout -p
to remove the hunks I don't want going backward.