I'm trying to force push a rebase of a feature branch to a remote repository. To be a bit safer, I'm trying to use --force-with-lease
to make sure no other changes have happened in the branch since I last fetched it.
This is failing for reasons I don't understand:
$ git branch
* my-branch
master
$ git push --force-with-lease origin my-branch -u
To gitlab.com:example/my-project.git
! [rejected] my-branch -> my-branch (stale info)
error: failed to push some refs to 'git@gitlab.com:example/my-project.git'
I tried a fetch to see if my local cache had somehow gotten out of sync:
$ git fetch
$ git push --force-with-lease origin my-branch -u
To gitlab.com:example/my-project.git
! [rejected] my-branch -> my-branch (stale info)
error: failed to push some refs to 'git@gitlab.com:example/my-project.git'
I tried simplifying the push command a bit:
$ git push --force-with-lease
To gitlab.com:example/my-project.git
! [rejected] my-branch -> my-branch (stale info)
error: failed to push some refs to 'git@gitlab.com:example/my-project.git'
I tried limiting the check to my branch:
$ git push --force-with-lease=my-branch:origin/my-branch
To gitlab.com:example/my-project.git
! [rejected] my-branch -> my-branch (stale info)
error: failed to push some refs to 'git@gitlab.com:example/my-project.git'
As you can see, it fails the same way every time.
Why is my push failing, and how do I fix it?