git selective revert local changes from a file

前端 未结 6 951
花落未央
花落未央 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:19

    I believe you can do it most simply with:

    git checkout -p 
    

    From the manpage:

       −p, −−patch
           Interactively select hunks in the difference between the 
           (or the index, if unspecified) and the working tree. The chosen
           hunks are then applied in reverse to the working tree (and if a
            was specified, the index).
    
           This means that you can use git checkout −p to selectively discard
           edits from your current working tree.
    

提交回复
热议问题