美文网首页Git
Git undo changes for a file in o

Git undo changes for a file in o

作者: JaedenKil | 来源:发表于2021-02-03 15:27 被阅读0次

Scenario:
In one specific commit, need to discard the changes for one file

Command:

git show commitId -- fileName | git apply -R

Refer to git-apply:

Reads the supplied diff output (i.e. "a patch") and applies it to files. When running from a subdirectory in a repository, patched paths outside the directory are ignored. With the --index option the patch is also applied to the index, and with the --cached option the patch is only applied to the index. Without these options, the command applies the patch only to files, and does not require them to be in a Git repository.

This command applies the patch but does not create a commit. Use git-am[1] to create commits from patches generated by git-format-patch[1] and/or received by email.

-R
--reverse
Apply the patch in reverse.

相关文章

网友评论

    本文标题:Git undo changes for a file in o

    本文链接:https://www.haomeiwen.com/subject/ttfmtltx.html