-2

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?

KexAri
  • 3,867
  • 6
  • 40
  • 80
  • 2
    Possible duplicate of [How to revert Git repository to a previous commit?](http://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – 1615903 Sep 23 '16 at 07:48

1 Answers1

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
  • 1
    If 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