New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push denied after deleting files with bfg #41

Open
nick-youngblut opened this Issue Apr 29, 2014 · 17 comments

Comments

Projects
None yet
6 participants
@nick-youngblut

nick-youngblut commented Apr 29, 2014

After deleting select files from my repo with bfg, I'm denied when using git push.

The commands that I used (repo name changed to protect the innocent):

git clone --mirror /path/to/my/repo.git
bfg -D file1 repo.git
bfg -D file2 repo.git
bfg -D file3 repo.git
cd repo.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive
git push

The output from 'git push'

Counting objects: 857, done.
Delta compression using up to 40 threads.
Compressing objects: 100% (280/280), done.
Writing objects: 100% (817/817), 6.25 MiB, done.
Total 817 (delta 513), reused 803 (delta 503)
remote: error: denying non-fast-forward refs/heads/develop (you should pull first)
remote: error: denying non-fast-forward refs/heads/feature/align_breakpoints (you should pull first)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To /var/git/sharchaea/genome_align/
! [remote rejected] develop -> develop (non-fast-forward)
! [remote rejected] feature/align_breakpoints -> feature/align_breakpoints (non-fast-forward)
! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to '/var/git/sharchaea/genome_align/'

Any idea what's going on?
Thanks

@rtyley

This comment has been minimized.

Owner

rtyley commented Apr 29, 2014

Can you tell me who's hosting the remote Git server? GitHub, BitBucket, perhaps an internal corporate service?

I think it's quite likely the remote server has been configured to reject non-fast-forward updates - meaning that it's disallowing history-rewriting! Does the remote have receive.denyNonFastForwards true set in it's config?

@nick-youngblut

This comment has been minimized.

nick-youngblut commented Apr 29, 2014

Sorry for not specifying that in my initial comment. I was trying to push to GitHub, so I'm guessing that history-rewriting is not the issue.

@rtyley

This comment has been minimized.

Owner

rtyley commented Apr 29, 2014

Are you sure you cloned with --mirror? Could you repeat the steps just to be sure?

http://rtyley.github.io/bfg-repo-cleaner/#usage

@nick-youngblut

This comment has been minimized.

nick-youngblut commented Apr 29, 2014

I repeated twice before I posted the original comment. The commands in my original comment pasted from my history (with file names changed).

@orthodoc

This comment has been minimized.

orthodoc commented May 10, 2014

I was unable to do a git push after deleting a file. I got the following error:

fatal: remote error: 
  You can't push to git://github.com/orthodoc/my.git
  Use https://github.com/orthodoc/my.git

I did use the --mirror flag when cloning

@rtyley

This comment has been minimized.

Owner

rtyley commented May 10, 2014

You cloned using a read-only url. This is why you couldn't push your
updated history back.

https://help.github.com/articles/which-remote-url-should-i-use
On 10 May 2014 23:31, "Biswajit Dutta Baruah" notifications@github.com
wrote:

I was unable to do a git push after deleting a file. I got the following
error:

fatal: remote error:
You can't push to git://github.com/orthodoc/my.git
Use https://github.com/orthodoc/my.git

I did use the --mirror flag when cloning


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-42756358
.

@orthodoc

This comment has been minimized.

orthodoc commented May 10, 2014

Does that mean that I have to clone like this:

git clone --mirror https://github.com/orthodoc/my.git
@rtyley

This comment has been minimized.

Owner

rtyley commented May 10, 2014

Yup - use either that or the SSH url. The generic git protocol you're using
is not passing any authentication credentials, so GitHub is obviously not
going to accept pushes to your repo!
On 10 May 2014 23:44, "Biswajit Dutta Baruah" notifications@github.com
wrote:

Does that mean that I have to clone like this:

git clone --mirror https://github.com/orthodoc/my.git


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-42756652
.

@orthodoc

This comment has been minimized.

orthodoc commented May 10, 2014

I did that. Successfully pushed the changes. Some refs failed to go through. Probably Issue #36 that you have already explained. I checked history of my repo and the its squeaky clean. bfg made my day. I can't thank you enough.

@nishatafshan

This comment has been minimized.

nishatafshan commented Jan 18, 2016

Hi,
I am facing similar issue. I have cloned using ssh url.
git clone --mirror ssh://git@server/repo.git

java -jar bfg-1.12.8.jar --strip-blobs-bigger-than 100M repo.git
cd repo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive

Above steps cleans my repo.git from 6.4G to 1.2G. Later I try to push.
git push

But I get below error:-
Counting objects: 217307, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (80946/80946), done.
Writing objects: 100% (214361/214361), 666.42 MiB | 1.15 MiB/s, done.
Total 214361 (delta 118358), reused 209184 (delta 114750)
remote: You are attempting to update refs that are reserved for Stash's pull request
remote: functionality. Stash manages these refs automatically, and they may not be
remote: updated by users.
remote:
remote: Rejected refs:
remote: refs/pull-requests/190/from
remote: refs/pull-requests/247/from
remote: refs/pull-requests/247/merge
To ssh://git@server/repo.git
! [remote rejected] Branch -> Branch (pre-receive hook declined)
...
error: failed to push some refs to 'ssh://git@server/repo.git'

How should i fix it. Should I try with https url?

@javabrett

This comment has been minimized.

Contributor

javabrett commented Jan 19, 2016

The error message is fairly clear - Stash won't let you push refs under "pull-requests". There's a few things you could do, including renaming that branch in your local, making it non-tracking, deleting it etc. I don't know what the impact on clean-up will be in Stash if it is retaining those refs - maybe there is a clean-up process for those.

@nishatafshan

This comment has been minimized.

nishatafshan commented Jan 20, 2016

@javabrett You are correct. I had to get rid of the pull requests. I got them merged / declined and then started with the bfg clean up steps. There is another way to get rid of pull request from mirror clone - http://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html

@nishatafshan

This comment has been minimized.

nishatafshan commented Jan 26, 2016

@javabrett @rtyley Would you have any ideas on how to resolve below issue.

Post cleanup when I try push I am getting below error:-
Counting objects: 218648, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (81662/81662), done.
Writing objects: 100% (215818/215818), 666.89 MiB | 1.07 MiB/s, done.
Total 215818 (delta 119117), reused 210562 (delta 115381)
remote: Communication breakdown with Stash.
To ssh://repo.git
! [remote rejected] Branch ->Branch (pre-receive hook declined)
! [remote rejected] CUC-112 -> CUC-112 (pre-receive hook declined)
...
error: failed to push some refs to 'ssh://repo.git'

@javabrett

This comment has been minimized.

Contributor

javabrett commented Jan 26, 2016

It looks like a hook, pre-receive hook, is declining the push, but may be doing-so silently. You need to establish why that hook is rejecting the pushes to those refs, which may involve making the hook output more-verbose. Perhaps those refs are locked/protected by Stash.

@nishatafshan

This comment has been minimized.

nishatafshan commented Jan 27, 2016

@javabrett there are no explicit hooks set in stash for the repo. How do I find pull more details to judge the cause?

@javabrett

This comment has been minimized.

Contributor

javabrett commented Jan 27, 2016

I recommend:

  • web search of that error message and go through the list of possible causes
  • checking the Stash server logs
  • contacting Atlassian support
@akaguny

This comment has been minimized.

akaguny commented Jan 11, 2018

in work with github i see the same errors (clean with -rt flag):

 ! [remote rejected] refs/pull/8/head -> refs/pull/8/head (deny updating a hidden ref)
error: failed to push some refs to 'git@github.com:***/***.git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment