Undo a Git commit after push using reverse patch?

后端 未结 3 1610
广开言路
广开言路 2020-12-12 16:54

I\'ve pushed a commit and I want to revert changes introduced by this commit by applying and committing a reversed patch. How do I do it?

相关标签:
3条回答
  • 2020-12-12 17:21

    simply use

    for committed file:

    git revert <SHA1 ID>
    

    for non-committed file:

    git reset --hard HEAD
    
    0 讨论(0)
  • 2020-12-12 17:26

    Use

    git revert HEAD
    

    This will create a patch that reverts the last commit and commit that patch as a new commit.

    If you want to revert a specific earlier version, use

    git revert <revision>
    

    see also: http://schacon.github.com/git/git-revert.html

    0 讨论(0)
  • 2020-12-12 17:31

    Sounds like you want to use git-revert.

    https://www.kernel.org/pub/software/scm/git/docs/git-revert.html

    0 讨论(0)
提交回复
热议问题