Can you undo the "git reset HEAD~1" command?

Asked

Viewed 3,123 times

1

I was wanting to go back to the last commit performed, and nothing works anymore, I was wondering if you can undo the git reset command

  • Dude, I think this should solve git reset 'HEAD@{1}'

  • Take a look at this answer: https://stackoverflow.com/questions/2510276/undoing-git-reset

  • I took from that same reference that @Israelmerljak commented, I tested here a lero code that I have and it worked.

  • I’ve actually tried this @Israelmerljak, but I still haven’t been able to recover

  • I was actually making an error on the packages in node_modules (npm libraries), I reentered the files, the errors disappeared and others appeared, I ran git reset, and my page can’t load the files anymore. js

  • you would recommend me to pull from the remote bitbucket repository? to thinking about deleting everything and pulling from the repository.

Show 1 more comment

1 answer

2

Guys after researching a little I found a very interesting material that helped me a lot, follow the link: http://minicursogit.github.io/#/

1º Whenever there is a pertinent modification to your code, remember git commit:

Thanks to the good dad I have good practice commiting whenever a modification is made on the system, even though I had little practice with git, and I had the commit from the previous day where it was all working, save some very irrelevant modifications.

2nd undoing unwanted changes in git:

  • git checkout

"If I regret my last alterations?"

"You can discard changes in your Working directory by returning the state of your files to the last saved in staging area."

Since it can be done from the id of your commit or from your files, examples:

  • git checkout id_commit
  • git checkout file
  • git checkout . (executed command)

inserir a descrição da imagem aqui

  • good explanation, good that managed to solve alone +1

  • I’ll leave my +1 too, starting at Git I see that’s an excellent answer!

  • Thank you guys, I really enjoyed the material

Browser other questions tagged

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