【问题标题】:Force Git push on SourceForge强制 Git 推送 SourceForge
【发布时间】:2015-10-16 22:06:06
【问题描述】:

我正在尝试回滚 SourceForge 上的 Git 存储库。我尝试了以下方法:

git reset --hard 9ac2e31ca4a155d4c36780b4329626045a7f40ed
HEAD ist jetzt bei 9ac2e31 Fix warnings


git push -f origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To ssh://user@git.code.sf.net/p/project/code
 ! [remote rejected] master -> master (non-fast-forward)
error: Fehler beim Versenden einiger Referenzen nach 'ssh://user@git.code.sf.net/p/project/code'

如何覆盖远程 SourceForge Git 存储库的 master 分支?

【问题讨论】:

标签: git version-control git-push sourceforge


【解决方案1】:

由于denyNonFastforwards 是服务器端配置,您需要以某种方式访问​​您在 SourceForge 端的存储库。

作为您的ticket mentions,这是通过interactive shell service 完成的,但前提是您可以使用 ssh 打开安全外壳。

在 shell 中运行“sf-help --scm”会显示你的 repo 路径。
只需将denyNonFastforwards = true 调整为false 一点,进行推送,然后将其设置回true(为了安全起见)。

但是,像“ssh: connect to host shell.sourceforge.net port 22: Connection refused”这样的消息可能意味着:

  • 它可能在客户端被阻止(检查您是否可以通过 ssh 连接到其他服务,例如 GitHub,即使它不是交互式会话)
  • 或者它可能是 SourceForge 端中断的结果(但他们的status page doesn't report any recent incident

仔细检查SourceForge SSH documentation

【讨论】:

  • @LimitedAtonement 这是可能的,我不熟悉 sourceforge 将如何处理它(现在或 4 年前)
【解决方案2】:

以下是连接到您的 Sourceforge 帐户并更改 config 文件并启用 non-fast-forward 更新的详细说明。

您可以使用以下命令从您的计算机更改标准 Sourceforge 项目的denyNonFastForwards

  • 使用交互式 Shell 和命令 ssh -t ron190ron190@shell.sourceforge.net create 连接到您的 SSH 帐户。请注意,该 URL 与您的项目不同:
$ ssh -t ron190ron190@shell.sourceforge.net create
The authenticity of host 'shell.sourceforge.net (ip)' can't be established.
ECDSA key fingerprint is SHA256:key
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'shell.sourceforge.net,ip' (ECDSA) to the list of known hosts.
Password:
Requesting a new shell for "user" and waiting for it to start.
queued... creating... starting...
This is an interactive shell created for user user,users
Use the "timeleft" command to see how much time remains before shutdown.
Use the "shutdown" command to destroy the shell before the time limit.
For path information and login help, type "sf-help".
  • 使用sf-help --scmpwd找到文件config,它应该位于文件夹/home/git/p/myproject/code.git/中。

  • 读取config文件查看denyNonFastforwards状态,确实设置为true:

[user@shell-22003 code.git]$ cat config
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = true
        sharedrepository = 2
    [receive]
        denyNonFastforwards = true
  • 启动vi修改文件,将true改为false
[user@shell-22003 code.git]$ vi config
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = true
        sharedrepository = 2
    [receive]
        denyNonFastforwards = false
    ~
    ~
                            1,1           All
  • 输入:w 保存更改,输入:q 退出vi。

错误denying non-fast-forward 应该不会再出现了。

【讨论】:

    【解决方案3】:

    如果是一次性的(或不频繁),您可以简单地使用git push -d sf branch 和推送删除远程分支。

    【讨论】:

      猜你喜欢
      • 2021-12-19
      • 2015-10-02
      • 2021-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      相关资源
      最近更新 更多