What is the difference between a “return”, “change”, “rollback” and “undo” of a commit?

Although I often use Git, I'm still a beginner.

Sometimes I make a mistake, but I see it only after I made it. At this point, I usually have to spend a lot of time on the Internet, looking for a command that I have to use to get rid of it (before clicking).

Every time this happens, I find myself at a loss, what is the difference between the four terms that I usually come across:

  • to return,
  • change
  • Rollback
  • cancel.

I finally have time to find out these differences once and for all. What they?

+6
source share
3

, , Git. , .

...

... ( ) , , . , , - (.. ).

, <commit>,

    git revert <commit>

...

... "" , ; git -amend , ?

enter image description here

,

  • , , , ( "" , , , );
  • ; , (, ).

    , ,

    git commit --amend
    

    - , - , . , .

...

... ( ) ( , ) , .

    git reset <commit-before-things-started-to-go-belly-up>

...

... , , , .

+7

git --amend git --amend , git. git --amend , .

git git revert. . , .

[ ] [1]

[1]: (reset) git ?

+1

: git checkout, git revert, git reset, git clean

  • git revert: . .
  • git reset: . , reset, . . . , .

    • git reset --soft HEAD^ ,
    • git reset --hard HEAD^
    • git reset --hard HEAD^^ 2
  • git commit --amend, modify . . , abc.txt , : git add abc.txt git commit --amend -m "New commit message"

+1

Source: https://habr.com/ru/post/1653227/


All Articles