0

I have merged some commits to develop branch (remote) and now want to roll back.

So I tried making a copy of develop and tried this on develop_copy

git reset --soft HEAD~1

I did ran the above command few times to the commit where it was all fine.

Now when I tried to do push it gives me error as:

updates were rejected because the tip of your current branch is behind

Not sure what needs to be done now, if I do git pull then I get all those commits I rejected with the above command back in my branch.

Can anyone tell me what do I need to do above to push my branch with the changes? Is there a better way to rollback?

My master is also up to date so I can also copy all from my master to develop if there is this option to do so.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Brenda
  • 510
  • 3
  • 13
  • 36
  • 1
    You can use `git push --force` to force your local branch into remote, use with caution as it will "overwrite" the remote branch. – roberto-gutierrez Oct 08 '20 at 21:05
  • 1
    If you've already pushed to the remote, then when you drop some of the commits it's inevitable that your local will now be behind the remote and when you pull those commits will reappear. – jonrsharpe Oct 08 '20 at 21:07
  • You need to to a rollback in your git repository, not locally. Why would you even want to do a soft reset and then commit it? – Rickard Elimää Oct 08 '20 at 21:11
  • Does this answer your question? [How can I rollback a github repository to a specific commit?](https://stackoverflow.com/questions/4372435/how-can-i-rollback-a-github-repository-to-a-specific-commit) – Calum Halpin Oct 08 '20 at 22:14

0 Answers0