1

I've looked at Resetting remote to a certain commit and it no longer seems to work.

I have a repo that's in sync with remote master. The remote is not seen by anyone else, so I feel okay with doing this: I want to remove the last commit from the remote (and re-apply an amended commit). I try the formulas I see there and get errors. Example:

kevin@camelot-x:~/Desktop/Projects/qubic/qubist$ git push --force origin 105bd79119e069b9a1678d37c47a7e66db5b858a:master
Password: 
Total 0 (delta 0), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To ssh://kogorman@git.code.sf.net/p/qubic/git
 ! [remote rejected] 105bd79119e069b9a1678d37c47a7e66db5b858a -> master (non-fast-forward)
error: failed to push some refs to 'ssh://kogorman@git.code.sf.net/p/qubic/git'
kevin@camelot-x:~/Desktop/Projects/qubic/qubist$

Other formulas give essentially the same complaint.

kowsky
  • 12,647
  • 2
  • 28
  • 41
4dummies
  • 759
  • 2
  • 9
  • 22
  • I haven’t used SourceForge in a long time (and not for Git projects), but that sounds like a protected branch feature – i.e. the remote repo has been configured to not allow you to rewrite history. If it belongs to you, you should have permission to turn that off temporarily somewhere in the web interface. – Ry- Dec 12 '18 at 00:28
  • have you tried this? https://stackoverflow.com/a/8225166/8815185 – nemanja Dec 12 '18 at 00:38
  • @Ry I am the sole admin for this project. I took a look at the web interface and was unable to find anything to adjust how git works. So I'm still stuck. – 4dummies Dec 12 '18 at 01:19
  • SourceForge perhaps protect repositories from forced push. SF stores bare repos in file system so you can login with [ssh](https://sourceforge.net/p/forge/documentation/SSH/) and edit `.git/config` or run `git config receive.denyNonFastforwards false` in the repo. See https://stackoverflow.com/q/12450703/7976758. – phd Dec 12 '18 at 01:30
  • @Nermanja I am having no luck with the answer you reference. For instance: "git push origin +HEAD^" is rejected because "fatal: remote part of refspec is not a valid name in +HEAD^" – 4dummies Dec 12 '18 at 01:35

1 Answers1

1

Following a comment from user named phd, I have a solution. The comment said

"SourceForge perhaps protect repositories from forced push. SF stores bare repos in file system so you can login with ssh and edit .git/config or run git config receive.denyNonFastforwards false in the repo. See stackoverflow.com/q/12450703/7976758."

So I used SSH for the first time on sourceforge in about a decade, and found this was exactly right. In particular,

ssh -t USER@shell.sourceforge.net create

(with my username instead of USER) got me started and I edited thus:

vim /home/git/p/PROJECT/git.git/config

(with the project name substituted)

There was a permission I had to change to this:

denyNonFastforwards = false

Then all that problematic stuff suddenly started working as documented. Now I'll change it back, because this should be somewhere between rare and unique.

4dummies
  • 759
  • 2
  • 9
  • 22
  • I now wish I had included a reference to SourceForge in the question title, because it turns out to be specific to SourceForge. – 4dummies Dec 12 '18 at 02:09