Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I revert commits directly on GitHub?

Tags:

git

github

It seems like you can do just about everything else directly on GitHub using the web interface, like edit and create and delete files, but I am unable to find a way to revert a commit, like you can in the GitHub local apps (Windows, and Mac) and like you can do on the git command line.

I'm just wondering am I just missing something. Is the revert button hidden?

I tried searching online and came across something that seemed to suggest that this was to prevent synchronization errors when working with lots of people. Is this correct?

like image 520
phocks Avatar asked Aug 03 '14 05:08

phocks


People also ask

How do I revert a commit in Github command line?

Steps to revert a Git commitLocate the ID of the commit to revert with the git log or reflog command. Issue the git revert command and provide the commit ID of interest. Supply a meaningful Git commit message to describe why the revert was needed.

Can I revert commit before push?

If you made a mistake on your last commit and have not pushed yet, you can undo it. For example, maybe you added some files and made a commit, and then immediately realized you forgot something. You can undo the commit, and then make a new (correct) commit. This will keep your history cleaner.


2 Answers

You can't revert back to that commit on the GitHub web site, there is no option to do this action, Instead, you should use command-line or GitHub Desktop as below

enter image description here

After REVERT, do not forget to PUSH the code. For more details, check the link How to restore deleted files on GitHub website?

like image 33
Mohamed Avatar answered Sep 19 '22 10:09

Mohamed


No, that feature isn't directly available on the GitHub web interface (as opposed to the "Revert" button recently added for GitHub for Mac/Windows)

Actually, it is for pull requests only, since June 24th, 2014:

Introducing the Revert Button

you can easily revert a pull request on GitHub by clicking Revert:

https://camo.githubusercontent.com/0d3350caf2bb1cba53123ffeafc00ca702b1b164/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6c696e6b2e706e67

You'll be prompted to create a new pull request with the reverted changes:

https://camo.githubusercontent.com/973efae3cc2764fc1353885a6a45b9a518d9b78b/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6e65772d70722e706e67


git revert is a bit more complex to manage through the web as it can accept a range of commit.
It shouldn't be an issue in term of collaboration though: a revert adds a new commit, it doesn't change the history of existing commit.

like image 144
VonC Avatar answered Sep 20 '22 10:09

VonC