Git revert just some files in commit

This question already has an answer here:

  • Reset or revert a specific file to a specific revision using Git? 28 answers

  • You can use git checkout:

    git checkout HEAD~ -- file/to/revert
    

    to stage a version of the file from the previous commit. Then just commit the changes and you're good to go! Of course, you can replace HEAD~ , which references the previous commit, with a hash of a commit, a further-back ancestor, or any "tree-ish" object you wish.


    I have few commits on github that I want to change.
    I need to revert changes only for some of them


    Few options:

  • Checkout the desired files from the desired commit

    git checkout <commit> path/to/file
    

  • Interactive rebase

    // X is the number of commits you wish to edit
    git rebase -i HEAD~X
    
  • Once you squash your commits - choose the e for edit the commit.

    在这里输入图像描述


    链接地址: http://www.djcxy.com/p/8974.html

    上一篇: 我怎样才能恢复分支之间的uncommited文件?

    下一篇: Git只提交一些文件