我正在尝试强制推送一个特性分支的衍合到远程仓库。为了更加安全,我正在尝试使用--force-with-lease
来确保自上次获取以来该分支没有发生其他更改。
由于我不理解原因,这个操作失败了:
$ 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'
我尝试了一次获取(fetch)操作,以查看我的本地缓存是否出现了某些不同步的情况:$ 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'
我尝试简化push命令:
$ 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'
我尝试将检查限制在我的分支中:
$ 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'
正如你所看到的,它每次都以相同的方式失败。
为什么我的推送失败了,我该怎么修复它?
my-branch
上游已经存在一个设置吗?如果是的话,它是什么? (2)origin
的获取 refspec 是什么? - torek--prune
选项在pull/fetch时可以纠正这个问题。 - Laurence Gonsalves