我试图在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
分支?
答案 0 :(得分:4)
由于denyNonFastforwards
是服务器端配置,因此您需要以某种方式访问SourceForge端的repo。
作为您的ticket mentions,这是使用interactive shell service完成的,但假设您可以使用ssh打开安全shell。
在shell中运行“
sf-help --scm
”会显示您的回购路径 只需将denyNonFastforwards = true
稍微调整为false
,然后按下,然后将其重新设置为true
(为安全起见)。
但是,“ssh: connect to host shell.sourceforge.net port 22: Connection refused
”之类的消息可能意味着:
答案 1 :(得分:3)
以下是连接到您的Sourceforge帐户并更改config
文件并启用non-fast-forward
更新的详细说明。
您可以使用以下命令从计算机更改标准Sourceforge项目的denyNonFastForwards
:
ssh -t ron190ron190@shell.sourceforge.net create
的Interactive Shell连接到您的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".
使用config
或sf-help --scm
查找文件pwd
,该文件应位于/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
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
不应再出现了。
答案 2 :(得分:0)
如果这是一次性的事情(或不经常发生),则只需使用git push -d sf branch
和下推即可删除远程分支。