Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git reversing mistake [duplicate]

Tags:

git

Recently, one of the contributors to our project made a commit which broke our system. I am trying to revert back to the latest working release:

I use git log to find the commit:

commit 45359d69e7983946b233d9010f205be19ce8ebfe
Author:Tom
Date:   Mon Apr 14 14:59:50 2014 +0100

    Tweaks the interface to make it more clean

I then do:

git checkout 45359d69e7983946b233d9010f205be19ce8ebfe

Followed by:

git add -A && git commit -am "revert"

And I finally try:

git push

Which returns:

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'path'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

(Where it says path I just removed the url of the server)

Any thoughts?

like image 383
Dario Avatar asked Apr 27 '14 12:04

Dario


1 Answers

To revert a commit with git, use git revert $commit. It will create new commit with the reverse changes (so you will be back at the original version without the changes).

like image 183
knittl Avatar answered Nov 12 '22 16:11

knittl