-1

I have an app hosted on OpenShift, which allows deploying apps by adding it as a Git remote and pushing changes to it.

I have added some code that breaks the server startup, so I would like to rollback to a previous commit. To do this I attempted to push the commit to the remote repo with: git push openShiftRemote 6f0c6aa5d397e2ac46f34e533d2e33e3d7dde625:master

Git rejects this, responding with this message: Updates were rejected because a pushed branch tip is behind its remote

It sounds like I should be able to make it work by including the -f flag to force the push. I have a separate remote that exists for pulling, etc. The OpenShift remote exists entirely for deployment, so I don't think using -f would break anything.

Is this safe? And more importantly, is this the best way to accomplish this?

twiz
  • 9,041
  • 8
  • 52
  • 84

1 Answers1

1

I don't know about OpenShift, but you can easily revert a commit in git. Do 'git log' and get the commit hash of your commit, which is faulty.

git revert <commit-hash>
git push origin <branch-name>

Git will revert your previous commit, and it is logically same as doing rollback to previous checkin.

Using 'revert' is better than doing rollback, in most cases, because you can keep track of what you did and also, you can reuse the code when you want again.

MadCoder
  • 641
  • 6
  • 16