Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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. rollback this commit - roll back this commit leaving all changes made in this and later commits in your working directory

Could you explain the exact meaning of these two commands and how they can be used. Specifically I fail to understand what is the purpose of the second one. It makes no sense to me.

Is it possible to revert to a previous commit check it out and if I don't like it, go back to where it was initially?

This gui seems to feature a very small part of the git system but what would be a proper workflow utilizing it?

like image 939
Zingam Avatar asked Feb 23 '13 10:02

Zingam


People also ask

What does it mean to revert a commit in git?

Summary. The git revert command is a forward-moving undo operation that offers a safe method of undoing changes. Instead of deleting or orphaning commits in the commit history, a revert will create a new commit that inverses the changes specified. Git revert is a safer alternative to git reset in regards to losing work ...

What happens if you revert a revert commit?

Unlike git reset , git revert doesn't remove the commit from the project history but inverts the changes introduced by the selected commit and appends a new commit with the resulting inverse content.


2 Answers

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.

like image 110
JB Nizet Avatar answered Sep 18 '22 21:09

JB Nizet


Is it possible to revert to a previous commit check it out and if I don't like it, go back to where it was initially?

It is now (March 2013), with GitHub for Windows, you can undo a rollback without having to type any git command:

See "Undo Button in GitHub for Windows"

we've added Undo support for Discards, Commits, Rollbacks, and Merges:

Undo button

like image 41
VonC Avatar answered Sep 21 '22 21:09

VonC