📌  相关文章
📜  git revert only part of commit - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:27.546000             🧑  作者: Mango

代码示例1
Use the --no-commit (-n) option to git revert, then unstage the changes, then use git add --patch:

$ git revert -n $bad_commit    # Revert the commit, but don't commit the changes
$ git reset HEAD .             # Unstage the changes
$ git add --patch .            # Add whatever changes you want
$ git commit                   # Commit those changes
Note: The files you add using git add --patch are the files you want to revert, not the files you want to keep.