How can I reset or revert a file to a specific revision?

前端 未结 30 1804
不思量自难忘°
不思量自难忘° 2020-11-21 11:23

I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous versio

30条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 11:42

    You can quickly review the changes made to a file using the diff command:

    git diff  
    

    Then to revert a specific file to that commit use the reset command:

    git reset  
    

    You may need to use the --hard option if you have local modifications.

    A good workflow for managaging waypoints is to use tags to cleanly mark points in your timeline. I can't quite understand your last sentence but what you may want is diverge a branch from a previous point in time. To do this, use the handy checkout command:

    git checkout 
    git checkout -b 
    

    You can then rebase that against your mainline when you are ready to merge those changes:

    git checkout 
    git rebase master
    git checkout master
    git merge 
    

提交回复
热议问题