git selective revert local changes from a file

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

    Looks like you want

     git revert --no-commit $REVSISON 
    

    You can then use

     git diff --cached
    

    to see what change will be made before commiting ( as reverting is just a commit in a forwards direction that replicates the inverse of a change in the past )

    If you were with a pure Git repository, you could possibly, depending on your goals, utilise interactive rebase (git rebase -i) to go back to the commit you didn't like and edit the commit retroactively so that the changes you don't like never happened, but thats generally only for if you KNOW you'll never want to see it again.

提交回复
热议问题