0

I deploy the code in one of my server with according to this tutorial:

How To Set Up Automatic Deployment with Git with a VPS

But now i have problems with some commit pushed to deploy server, some times the code inside of the githooks, make that make some test, this test fail, and i need revert the code when this happend, ideally this must be automatic, but just now i dont have problems making this rever to a specific commit mannually...

How i can revert the last push or push this server (based in git-bare) into a specific commit?

aasanchez
  • 179
  • 1
  • 16

1 Answers1

1

Because the branch in question is published, your best bet probably is to use git revert:

git revert <SHA-1a>..<SHA-1b>

where <SHA-1a> and <SHA-1b> are the commit ids of the first and last commits in a range of commits which you want to revert.

This will apply a number of revert commits, starting from most recent to oldest, which will undo the changes in the range.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • the problem with git revert, its git revert work in local https://www.atlassian.com/git/tutorials/undoing-changes/git-revert and i need revert the change its in remote, in the deploy server... – aasanchez Jul 05 '16 at 15:38
  • I don't understand. The deployed branch must have originated in a local branch somewhere. Is there some reason you can't revert the commits locally and then push? – Tim Biegeleisen Jul 05 '16 at 15:39
  • Should make clear to OP that this actually records a new commit that undoes the changes of a range of commits. This isn't what he thinks he wants, but it is the best he can get when a repo could have been pulled in the meantime. – evaitl Jul 05 '16 at 16:26
  • @evaitl I was originally going to post for just one commit, but I suspect that he has a bunch of commits he wants to revert. – Tim Biegeleisen Jul 05 '16 at 16:30
  • let me try to explain better... i have project, with 2 origins... $ git remote * live * origin where origin its apointing to gitlab server, and live its apointing to production server, the both have a master branch as principal, and sometimes when we push the comits to "live" server, as explain in the link than i put, the merge its failed and we need rollback just this server, but keep gitlab without changes, and after fix the error, push againg to live server... but the history in the branch dont must be change... – aasanchez Jul 06 '16 at 09:40