Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix a reverted git commit?

Tags:

git

commit

I've committed a bunch of changes to a repository, and they were reverted by someone else (they compile on windows but not on linux). I think that the changes are still in the history, but how can I get those changes back, fix them, and then resubmit?

like image 401
mmr Avatar asked Mar 18 '11 16:03

mmr


People also ask

What happens when a commit is reverted?

Instead of deleting or orphaning commits in the commit history, a revert will create a new commit that inverses the changes specified.


2 Answers

Have you tried reverting the revert?

They reverted your commit using

git revert <your commit id> 

The revert itself is a commit and has its own commit id. So now you need to do

git revert <the commit id of his revert-commit> 
like image 84
Nils Werner Avatar answered Sep 19 '22 15:09

Nils Werner


You can try reverting the reverts, using git revert. You can also restore the files from your commit using git checkout. Or you can use git cherry-pick -n to re-apply them and change them. You can create a new branch from your commit where you apply the changes using git branch. The possibilities are (almost) endless. :)

like image 45
Bombe Avatar answered Sep 21 '22 15:09

Bombe