8

I'm trying to rollback a Git repository on SourceForge. I tried the following:

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'

How can I override the master branch for a remote SourceForge Git repository?

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
  • Do you have the property denyNonFastforwards set as false in the config file, by any chance? – Juan Jul 26 '15 at 20:35
  • Maybe. I don't know. I found an [issue on SourceForge](https://sourceforge.net/p/forge/site-support/9558/) about this problem. – BuZZ-dEE Jul 26 '15 at 20:51
  • You may be able to delete the remote branch and then push master as a completely new branhc. – Thorbjørn Ravn Andersen Jul 26 '15 at 22:19
  • @ThorbjørnRavnAndersen I already tried to delete the remote master branch, but this does not work. – BuZZ-dEE Jul 27 '15 at 09:16
  • Possible duplicate of [Source Forge repo gives "denying non-fast-forward refs/heads/master" error](http://stackoverflow.com/questions/12450703/source-forge-repo-gives-denying-non-fast-forward-refs-heads-master-error) – Code-Apprentice May 01 '17 at 15:32

3 Answers3

5

Since denyNonFastforwards is a server-side config, you need to access to your repo on the SourceForge side somehow.

As your ticket mentions, this is done with an interactive shell service, but that supposes you can use ssh to open a secure shell.

Running "sf-help --scm" in the shell will show you your repo paths.
Just tweak the denyNonFastforwards = true to false for a bit, do your push, and then set it back to true (for safety).

However, a message like "ssh: connect to host shell.sourceforge.net port 22: Connection refused" could mean that:

  • It could be blocked on the client side (check if you can ssh to other services, like GitHub, even though it won't be an interactive session)
  • or it could be the result of an outage on SourceForge side (but their status page doesn't report any recent incident)

Double-check the SourceForge SSH documentation.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    @LimitedAtonement That is possible, I am not familiar how sourceforge would handle that on its side (now or 4 years ago) – VonC Jul 15 '19 at 19:05
4

Here are detailed instructions to connect to your Sourceforge account and change the config file and enable non-fast-forward updates.

You can change denyNonFastForwards of a standard Sourceforge project from your computer with the following commands :

  • Connect to your SSH account using Interactive Shell with command ssh -t ron190ron190@shell.sourceforge.net create. Notice that the URL is different from the one of your project:
$ 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".
  • Find the file config using sf-help --scm or pwd, it should be located in folder /home/git/p/myproject/code.git/.

  • Read the config file to check denyNonFastforwards status, it is indeed set to true:

[user@shell-22003 code.git]$ cat config
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = true
        sharedrepository = 2
    [receive]
        denyNonFastforwards = true
  • Start vi to modify the file, change true to false:
[user@shell-22003 code.git]$ vi config
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = true
        sharedrepository = 2
    [receive]
        denyNonFastforwards = false
    ~
    ~
                            1,1           All
  • Type :w to save the change and :q to exit vi.

The error denying non-fast-forward should not appear anymore.

ron190
  • 1,032
  • 1
  • 17
  • 29
0

If it's a one-time thing (or not frequent), you can simply delete the remote branch with git push -d sf branch and the push.

saeedgnu
  • 4,110
  • 2
  • 31
  • 48