Git revert certain files

前端 未结 3 1173
不思量自难忘°
不思量自难忘° 2020-12-16 13:26

I want to do a revert of a commit, but only for some files. (Not a checkout; a revert. If you are unfamiliar with the difference, keep reading.)

I tried thi

3条回答
  •  青春惊慌失措
    2020-12-16 13:42

    I don't think git lets you specify particular files to revert. The best I can think of is this:

    git revert --no-commit  # Revert, don't commit it yet
    git reset # Unstage everything
    git add yourFilesToRevert # Add the file to revert
    git commit -m "commit message"
    git reset --hard # Undo changes from the part of the revert that we didn't commit
    

提交回复
热议问题