How do I work with git when there are problems with the production version?

Asked

Viewed 49 times

0

I have an application in production that was working on a new module within a branch in my local repository, when I finished, and after testing, I did the Merger with the master I sent to the server. Soon after I found a big problem in the application, I tried to do a direct checkout on the server but I could not because I had problems with the console, then I ended up using the server’s own rollback to reverse.

My doubt is about what would be the most correct way to work in a situation like this by making use of git ?

1 answer

4


The way I think it’s safer is by using git reset --hard and passing the commit hash before the commit with issue.

To do this, first discover the commit hash, using git reflog, that will generate something like output:

git reflog
1234567 HEAD@{0}: commit (merge): Merge branch local/nome-da-branch into local/master
2345678 HEAD@{1}: commit: alguma alteracao qualquer
3456789 HEAD@{2}: commit (initial): Initial commit

In this case, the last merge was 1234567, so we want to go back to 2345678, so just run:

git reset --hard 2345678

You can also use the HEAD, thus:
git reset --hard HEAD@{1}

  • Cool, this will help me a lot, now I see that it was very easy to solve my problem. Thank you very much

  • yes works well, I’ve had to do some rollbacks :D don’t forget to mark the question if it helped solve the problem

Browser other questions tagged

You are not signed in. Login or sign up in order to post.