Reverting part of a commit with git

后端 未结 6 1867
闹比i
闹比i 2020-12-22 15:21

I want to revert a particular commit in git. Unfortunately, our organization still uses CVS as a standard, so when I commit back to CVS multiple git commits are rolled into

6条回答
  •  误落风尘
    2020-12-22 15:54

    Another alternative (if your current version of a file isn't too far from the version you're trying to revert) is to get the hash of the commit immediately before the one you wish to partially revert (from git log). Then your command becomes:

    $ git checkout -p  -- file/you/want/to/fix.ext
    

    This does change the files in your working tree but creates no commits, so if you really stuff up you can just start again with git reset --hard -- file/you/want/to/fix.ext.

提交回复
热议问题