Git: how to rewind a master branch in a remote source

I made 5 commits for the master branch when I looked for an error in a private project and pushed them to a remote source (my own private vps).

Then I saw that commits 4 and 5 would cause problems elsewhere, and I need to cancel them, so I checked commit 3 again, made a new “Dev” branch from that point and made a few more fixes fixing the problem properly.

Then i did

git reset - hard HEAD ~ 2 on Master to return it to the point where I forked Dev.

Then I did a git merge to speed forward to the end of the Dev branch.

So now I have a local repository with Dev and Master, which point to the same updated version of the project with the latest bug fix.

The problem is that when I try to push the project to the beginning, it fails and gives me an error message:

! [rejected] master → master (no fast forward) Error: could not click some links to "myserver ... myproject.git"

What have I done wrong and how to fix it?

thank

+3
source share
1 answer

I just don't like the fact that the branch you click on is not the ancestor of what you click on.

If you are sure you want to do this, simply add the -f (force) flag to the click.

+5
source

Source: https://habr.com/ru/post/1738783/


All Articles