Revisit: Resetting remote to a certain commit

70 Views Asked by At

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://[email protected]/p/qubic/git
 ! [remote rejected] 105bd79119e069b9a1678d37c47a7e66db5b858a -> master (non-fast-forward)
error: failed to push some refs to 'ssh://[email protected]/p/qubic/git'
kevin@camelot-x:~/Desktop/Projects/qubic/qubist$

Other formulas give essentially the same complaint.

1

There are 1 best solutions below

1
4dummies On

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 [email protected] 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.