0

There is a certain commit I did to my Git repository which I host in GitHub. After that commit I've made several other commits, which were bad and redundant, in a second look. I thus need to revert to the certain commit / certain point in history before these bad changes.

I didn't find a button like "revert to this version" or "commit this version as the head of this branch (master)".

As you can see, I just want to make that older version the head of the master branch. How will you do that from GitHub?

Update

I emphasize: I ask on GitHub, not on git or any GUI other than GitHub.

Don Branson
  • 13,430
  • 10
  • 57
  • 100
user9303970
  • 1,283
  • 1
  • 8
  • 15
  • Possible duplicate of [How to revert Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – Steven Feb 04 '18 at 19:22
  • Again, I asked on GitHub. Not on Git. This is NOT a duplicate. – user9303970 Feb 04 '18 at 19:25
  • 1
    You should perhaps delete the `git` tag, then; you're likely to get many Git-only answers. I don't believe GitHub *can* do this, though. – torek Feb 04 '18 at 19:29

1 Answers1

2

If I understand you correctly you want a past commit as the last commit on the branch. If so, using examples with origin and master:
Use git reset <comit_id> and then git push origin +master to push & delete all commits past the one you reset to.
Notice the + sign before the branch name (master).
Note that this is irreversible (as far as I know) so take the necessary precautions.

Evyatar Meged
  • 2,196
  • 2
  • 10
  • 19
  • Sorry for budging in, I didn't know about the + sign myself, is this what deletes the previous commits? – Steven Feb 04 '18 at 19:31
  • 1
    @Steven Yep. If you reset to a past commit locally and then push with the + sign, all commits in the branch after the one you reset to will be deleted. – Evyatar Meged Feb 04 '18 at 19:33