Git

Git undo changes for a file in o

2021-02-03  本文已影响0人  JaedenKil

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.

上一篇下一篇

猜你喜欢

热点阅读