为什么我的 git 总是强制推动?

Wil*_*ong 5 git gitlab

似乎我的本地安装git(版本 2.10.2)是这样的,每当我发出时git push,它都会被解释为git push -f. 是否有一个配置变量我可能设置不正确导致这种行为?

更多背景

最近,我使用的服务器升级了他们的 GitLab 安装(运行社区版 8.14.2 b9442a5eb0,不幸的是,我没有简单的方法可以找出以前的版本是什么)。对于我拥有的每个项目(并拥有主许可),我得到

[Tue Dec 06 02:21 PM] ArchDesktop $ git push 
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 765 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To REDACTED
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'REDACTED'
Run Code Online (Sandbox Code Playgroud)

我认为这是由于在最新版本的 GitLab 中实现了“受保护的分支”。现在,我应该能够推送东西了,因为我拥有对自己项目的 Master 访问权限。此外,如果只是权限问题,我理解错误消息应该阅读

remote: GitLab: You are not allowed to force push code to a protected branch
Run Code Online (Sandbox Code Playgroud)

没有提到强制推动。所以真正的问题是:当我没有告诉它时,为什么 Git 试图强制推送我的提交?

更多背景

曾几何时,我阅读了 Git 的工作原理并真正理解了它。然后我开始使用它并且基本上已经忘记了。因此,我完全有可能在做一些完全错误的事情并且不理解它。我什至不确定如何诊断这个问题。因此,欢迎对我需要在这个问题中包含的内容或我应该检查的明显事项提出任何意见!


附加信息

根据要求:git config --list仅提供(除了我的姓名、电子邮件和回购网址)

user.name=*******
user.email=******
push.default=simple
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=**************
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
Run Code Online (Sandbox Code Playgroud)

稍微编辑的输出GIT_TRACE=1 git push

09:13:50.859273 git.c:349               trace: built-in: git 'push'
09:13:50.859524 run-command.c:336       trace: run_command: 'ssh' 'git@gitlab.REDACTED' 'git-receive-pack '\''REDACTED.git'\'''
09:13:54.097551 run-command.c:336       trace: run_command: 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
09:13:54.098218 exec_cmd.c:120          trace: exec: 'git' 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
09:13:54.100884 git.c:349               trace: built-in: git 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 389 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To REDACTED
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'REDACTED'
Run Code Online (Sandbox Code Playgroud)

Wil*_*ong 3

我联系了我们友好的当地 GitLab 管理员,结果发现这是一个已知的错误

当 GIT 版本 2.11.0 与 Gitlab v. 8.11.x - 8.14.2 结合安装时,即使拥有正确的权限,Master 或 Developer 也无法推送到受保护的分支。

通过阅读评论,似乎原因已经找到(尽管我自己无法理解太多),并且可能会在将来的版本中解决。

管理员向我指出的一件事(这也解释了为什么我在搜索时自己没有发现这个错误)是,重要的是服务器上的git 版本。当我在本地运行 2.10.2 时,是他们服务器上的 2.11.0 更新导致了问题。因此,当我查找 2.10.2 和 GitLab 之间的具体冲突时,我没有找到任何冲突。