git selective revert local changes from a file

前端 未结 6 952
花落未央
花落未央 2021-01-29 18:55

In my git repo which is tracking a svn repo I have made a number of edits to a single file.

Now I want to revert those changes(like svn revert), but only portions of the

6条回答
  •  悲&欢浪女
    2021-01-29 19:21

    You could run git diff on the file, save the resulting diff, edit it to remove the changes you do want to save, then run it through patch -R to undo the remaining diffs.

    git diff file.txt >patch.tmp
    # edit patch.tmp to remove the hunks you want to keep
    patch -R 
        

提交回复
热议问题