I'm having trouble understanding how to go back to previous commit. Say I have a commit that's 5 commits back or so. I want to remove all the work since then and start from that commit. Do I need to do reset or revert?
Asked
Active
Viewed 168 times
1 Answers
1
Depends.
If you pushed it, better revert them on by one.
If you didn't, just git reset --hard HEAD~5
.

blue112
- 52,634
- 3
- 45
- 54
-
After git reset --hard HEAD~5 what commands do I need? Do I need to add files and commit and push? Or pull? – KexAri Sep 23 '16 at 07:49
-
1If you issued this command, this mean you've never pushed your repository. So no further step is required, enjoy your reseted repo. – blue112 Sep 23 '16 at 08:00
-
If I reset with `git reset --hard HEAD~5` and then make some changes and try to push I get `Updates were rejected because the tip of your current branch is behind`, how do I resolve this? – KexAri Sep 25 '16 at 08:52