Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on git push = ! [remote rejected] master -> master (pre-receive hook declined)

Tags:

git

bitbucket

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>' 
like image 671
paul Avatar asked Jan 28 '14 14:01

paul


People also ask

How do you solve remote rejected main -> main pre receive Hook declined?

[remote rejected] master -> master (pre-receive hook declined) error. Unprotect your master branch to solve the issue. If you can't push code directly to the master and get errors, you need to be the maintainer of the repo. Inserting incorrect details could also be a major cause of this error.

What does it mean that the pre receive hook is declined?

The “hook declined” error can also occur if the user does not have an accurate access right. It means that they are unable to push a commit to the relevant branch (for example, master). It is important to note here that the branch that is being pushed can be protected.

Why is Github rejecting my push?

A commit gets rejected and causes a failed to push some refs to error because the remote branch contains code that you do not have locally. What this means is that your local git repository is not compatible with the remote origin. Based on the above, your local machine is missing commits C and D.

How do you push origin master?

Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.


1 Answers

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

like image 60
First Zero Avatar answered Oct 16 '22 22:10

First Zero