What is the meaning of revert this commit and roll back this commit in GitHub for Windows?

后端 未结 2 1440
一个人的身影
一个人的身影 2021-02-01 01:17

Github for Windows features these two commands described as:

  1. revert this commit - create a new commit that reverts the changes of this commit
2条回答
  •  青春惊慌失措
    2021-02-01 02:00

    Suppose you have a single file in your repo, and you have the following commits:

    commit 1 : the file contains A
    commit 2 : the file contains B
    commit 3 : the file contains C
    

    If you execute revert on commit 3, you'll have this in the repo:

    commit 1 : the file contains A
    commit 2 : the file contains B
    commit 3 : the file contains C
    commit 4 : the file contains B
    

    And the file in your working copy will contain B as well.

    If you execute roll back, you'll have this in the repo:

    commit 1 : the file contains A
    commit 2 : the file contains B
    

    And the file in your working copy will be left unmodified. The file will thus contain C. It allows you to fix a small mistake and commit again, for example.

提交回复
热议问题