How to revert a folder to a particular commit by creating a patch

后端 未结 2 382
不思量自难忘°
不思量自难忘° 2020-12-22 18:59

Here\'s my history for the folder \'somefolder\'

$ git log somefolder

commit 89cd
More changes to somefolder

commit ef47a
Updating somefolder and other stu         


        
2条回答
  •  甜味超标
    2020-12-22 19:28

    You can use git reset to reset the index which will also include removing files that were added in more recent commits (git checkout on it's own doesn't do this):

    git reset e095 -- somefolder
    

    However git reset doesn't update the working copy and the --hard option doesn't work with folders. So then use git checkout to make the working copy the same as the index:

    git checkout -- somefolder
    

    and then if you also want to remove any files added you also need todo:

    git clean -fd somefolder
    

提交回复
热议问题