Let's say you wanted to push some code modifications, so you added a source (or so you thought), but realize after commit & push, that what you really added was the binary rather than the .c. Don't want your public repo to be polluted by unneeded binaries.
So you tried:
git reset --hard HEAD~1 git push origin +master:masteror
git commit --amendbut every time you push you get the error:
error: denying non-fast-forward refs/heads/master (you should pull first) To ssh://USER@PROJECT.git.sourceforge.net/gitroot/PROJECT ! [remote rejected] master -> master (non-fast-forward) error: failed to push some refs to 'ssh://USER@PROJECT.git.sourceforge.net/gitroot/PROJECT'What gives?
A good search will of course lead you to ticket #9187 and
receive.denyNonFastforwards
being set to true by default on the remote git repository provided by SourceForge.How can you edit your remote config to unset
denyNonFastforwards
? Easy:ssh -t USER,PROJECT@shell.sourceforge.net create [USER@shell-24010 ~]$ sf-help (...) Your project DSCM repositories are here (use adminrepo for CVS and SVN): /home/scm_git/U/US/USER.u /home/scm_git/P/PR/PROJECT (...) [USER@shell-24010 ~]$ cd /home/scm_git/P/PR/PROJECT [USER@shell-24010 PROJECT]$ ls -alFh total 12K drwxrwsr-x 3 dummy PROJECT 80 Nov 29 19:15 ./ drwxr-xr-x 3 root root 4.0K Feb 10 21:58 ../ drwxrwsr-x 7 dummy PROJECT 1.0K Nov 29 19:15 PROJECT/ [USER@shell-24010 PROJECT]$ cd PROJECT [USER@shell-24010 PROJECT]$ ls -alFh total 48K drwxrwsr-x 7 dummy PROJECT 1.0K Nov 29 19:15 ./ drwxrwsr-x 3 dummy PROJECT 80 Nov 29 19:15 ../ -rw-rw-r-- 1 dummy PROJECT 23 Nov 29 19:15 HEAD drwxrwsr-x 2 dummy PROJECT 80 Nov 29 19:15 branches/ -rw-rw-r-- 1 dummy PROJECT 126 Nov 29 19:15 config -rw-rw-r-- 1 dummy PROJECT 5 Nov 29 19:15 description drwxrwsr-x 2 dummy PROJECT 1.0K Nov 29 19:15 hooks/ drwxrwsr-x 2 dummy PROJECT 80 Nov 29 19:15 info/ drwxrwsr-x 133 dummy PROJECT 5.0K Feb 10 21:41 objects/ drwxrwsr-x 4 dummy PROJECT 80 Nov 29 19:15 refs/Yay, there's a config there:
[USER@shell-24010 PROJECT]$ vi configThen remove/unset that pesky
denyNonFastforwards
and you're good to go.