0

I am trying to roll back a git commit. On the local version of the repo, I can do

`git reset --HARD xxxxxxx` 

Where the xxxxxx is the hash, but how do I push the rollback to the master on github.com?

Just a git commit fails, since the local repo is behind the master.

Paolo
  • 21,270
  • 6
  • 38
  • 69
Igor Rivin
  • 4,632
  • 2
  • 23
  • 35

1 Answers1

1

You should use git revert (docs)

Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them.

You should use it to revert from HEAD to your specified commit with

git revert --no-commit <xxxxxxx>..HEAD
git commit

It is handy to use --no-commit, as stated in the docs, in case you have more commits to revert at once:

Usually the command automatically creates some commits with commit log messages stating which commits were reverted. This flag applies the changes necessary to revert the named commits to your working tree and the index, but does not make the commits. In addition, when this option is used, your index does not have to match the HEAD commit. The revert is done against the beginning state of your index.

This is useful when reverting more than one commits' effect to your index in a row.

Community
  • 1
  • 1
Balastrong
  • 4,336
  • 2
  • 12
  • 31