0

I am trying to clean up git repository. There are some identified big files whose size is reduced and recommitted. The issue is history still has old files. So I used bfg cleaner job to prune the git repo. For this I first create a mirror clone of repo and then do some filtering to reduce the size.

Clone command:-

git clone --mirror ssh://git@url/repo.git

I am successfully able to do clean up and reduce the size of the cloned mirror. Now I try to push it to the remote server. I use :-

git push

This fails with below error:-

Counting objects: 214329, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (80081/80081), done.

Writing objects: 100% (211535/211535), 666.00 MiB | 1.52 MiB/s, done.

Total 211535 (delta 116658), reused 206326 (delta 112960)

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

remote:     refs/pull-requests/269/from

remote:     refs/pull-requests/269/merge

remote:     refs/pull-requests/270/from

To ssh://git@url/repo.git

 ! [remote rejected] integration -> integration (pre-receive hook declined)

 ! [remote rejected] integration_after_mavenrework -> integration_after_mavenrework (pre-receive hook declined)

 ! [remote rejected] master -> master (pre-receive hook declined)

I am not sure why I am not able to push. I am having write permissions to the repo.

I am stuck and any help is appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
nishat
  • 947
  • 2
  • 8
  • 15
  • 2
    The messages are fairly clear - you can't push pull-request refs because Stash manages them. And you have some hooks set up on Stash which are preventing you from pushing directly to master, etc. – Oliver Charlesworth Dec 30 '15 at 12:37
  • Hello Oliver, I suspected the same but there are no hooks that I can find which are enabled. Would you know a command to get the list of server and client side active hooks? – nishat Dec 30 '15 at 12:40
  • Oliver Charlesworth - Nope this is not true. As i said there was no hooks set. I found the answer to the problem. For people facing the above issue have a look at https://confluence.atlassian.com/display/STASHKB/Pre-receive+hook+declined+when+pushing+large+number+of+tags – nishat Jan 04 '16 at 12:30

1 Answers1

2

The problem is here:

git push

You must be using old version of git <2.

In older version whenever you use git push/pull without any branch name after the command git push all you branches (modified) to the server.

In your case you must have cloned the pull request as well and not you try to push them back to stash server.

Stash rejects it and does not allow you to push those refs.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • You are right. When I mirror clone a repo even the pull requests gets cloned. Later when I try git push these references are rejected by Stash and hence the complete push fails. To solve the problem I got the pull requests in the repo merged/declined and then created a mirror. push then worked fine. – nishat Jan 21 '16 at 12:18
  • 1
    Read the first paragraph here. it will explain why its happening. https://git.kernel.org/cgit/git/git.git/tree/Documentation/RelNotes/2.0.0.txt – CodeWizard Jan 21 '16 at 12:20
  • If this answer is correct feel free to acccept and vote for it. – CodeWizard Jan 21 '16 at 12:21