52

I think, it's a different issue than this(remote rejected master -> master (pre-receive hook declined)), and many people are facing the same issue, So I am posting a new here.

My friend added me on bitbucket.org as an admin, so that I can help on his project. So, I wanted to start by taking a pull of the latest code on my local.

Steps I followed:

  1. Goto empty folder
  2. git init
  3. git remote -v (this gives nothing)
  4. git remote add origin <path to git repo>
  5. git remote add master <path to git repo>
  6. git remote -v (this show both with fetch and push in brackets)
  7. git fetch origin master
  8. git pull origin master (I have latest code now, all files and folders)
  9. touch test (lets test a "test" commit)
  10. git status
  11. git add .
  12. git commit -m "testing, first commit"
  13. git push origin master

error:

Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 274 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: permission denied to update branch master
To '<repo path>'
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '<repo path>'
turivishal
  • 34,368
  • 7
  • 36
  • 59
paul
  • 4,333
  • 16
  • 71
  • 144

8 Answers8

58

It looks like the branch management (one of the admin settings) in bitbucket has been configured to only allow certain people to push directly to master.

Try creating a branch - git checkout -b test, create your test commit and push git push origin test:test. You can always cleanly delete this branch once you have completed the test.

The other option (probably best agreeing with whoever set this up) is you go to bitbucket and head to admin, branch management and remove master be too limited. cf - https://confluence.atlassian.com/display/BITBUCKET/Branch+management

turivishal
  • 34,368
  • 7
  • 36
  • 59
First Zero
  • 21,586
  • 6
  • 46
  • 45
  • 1
    I didnt add myself for push to branch. Thanks the other option worked for me. – paul Jan 29 '14 at 06:39
  • Just add permission throught bitbucket WORked FOr Me – shareef Oct 07 '16 at 16:42
  • for me below command worked, git commit --amend --reset-author and then use git config user.email "Somnath.Kadam@domainname.com" git config user.name "Kadam, Somnath" and now git push origin master – Somnath Kadam Jun 20 '18 at 09:37
  • 1
    Same error came to me for another branch. I had set "Write access" to "Nobody" in "branch permissions". Making it to "Everybody" resolved the issue for me. – Pradeep Sanjeewa Nov 24 '21 at 06:43
  • In my case, I was a repository administrator. I was having the same problem until I added my individual account as having Write access to the branch. The Administrators group had Write access, but I hadn't been added there. After the main admin added me to the group, I didn't need the individual account. It sucks that I can mangle the repository configuration as an administrator multiple ways but I couldn't push source code changes as one. – Suncat2000 Jul 20 '22 at 15:31
4

Just reporting another case leading to the specified error. If the Bitbucket repository size reaches 2 GB, Bitbucket itself restricts the repository to read-only access. When that happens, contributors with read/write permissions are not able to push and get the "pre-receive hook declined" error.

I also found these documents from Atlassian: https://blog.bitbucket.org/2014/05/30/repository-size-limits/ https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html

Links include a guide on how to restore the repo back to full functionality

2

I have a better solution on Bitbucket: If you are admin go to Repo >Settings >Limit Pushes section, and in "Branch name" put 'master', and in "..search... user" put your user name - then push "ADD" - and you are done :)

turivishal
  • 34,368
  • 7
  • 36
  • 59
Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345
1

I think package setuptools/distribute is listed in requirements.txt. Please remove the same.

Savad KP
  • 1,625
  • 3
  • 28
  • 40
0

The same issue with me on gitlab, I asked the repo owner to grand me maintainer role and the issue fixed.

Abdul Manan
  • 2,255
  • 3
  • 27
  • 51
0

Another scenario -> I also had this issue and I also configured global parameters, tried branching etc but it didnt work for me.

Below was the issue -> I recently joined my current firm and till my Bitbucket credentials got activated, I was using someone elses credentials to access Jira, Bitbucket etc. Now this credetials got saved in Windows inside "Credential Manager". After deleting those other colleague credentials, it worked fine for me.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

I wanted to force push on my ticket branch, and it was rejected. Went to Repository settings -> Hooks -> found out that Reject Force Push was enabled, and disabled it.
Use at your own risk.

coffman21
  • 943
  • 11
  • 18
-1

What worked for me was:

  1. Created a new branch locally
  2. Bitbucket -> Settings -> Repository details = changed default branch (e.g to prod)
  3. Bitbucket -> Branches -> delete master branch (you can do this without step 2)
  4. Then push your locally created branch (e.g master)
  5. Bitbucket -> Settings -> Repository details = changed default branch (e.g to master)
Shina
  • 2,019
  • 2
  • 19
  • 25