Reversing the commit

Asked

Viewed 75 times

2

Talk guys, I have a problem in my repository.

I want to revert the repository to a previous commit, in which case it would be the commit that’s in red.

commit 2c593e6aa3d1a9f4c8f044618a04b2f2b5b57388 (origin/master, origin/HEAD)

inserir a descrição da imagem aqui

How do I do that?

1 answer

4


If you want to keep the last commit changes (they stayed in the Stage)

git reset --soft HEAD^

If you prefer to discard them

git reset --hard HEAD^

You can also tell the commit hash you want to point to

git reset --<soft|hard> 2c593e

See more details in the documentation of git reset

  • In case I want to rule it out, but --hard it removes only the first, is that it? And then in case it would be the day 27 at 14:11 ?

  • @Romulosousa What says is the first is the HEAD^ which means "go to the commit that’s right behind HEAD"

  • I understood, for me it would decide to use the commit 2c593e, soft would work. Just one question with that it would delete the commit that was wrong?

  • 1

    The two remove the commit. The difference is that the hard kills the modifications, you lose them. The soft keeps modifications in the Stage area.

  • Note that this will not change the remote repository, only the location.

  • 1

    @Romulosousa About the options of git reset, see here: https://answall.com/q/325951/112052

Show 1 more comment

Browser other questions tagged

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