Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pre-receive hook declined: No JIRA Issue found in commit message?

Tags:

git

jira

I've made a commit and am trying to push changes to the repo but it gives me this error.

remote: refs/heads/feature/OMT-1270-Missing-French-Translations: cd54ab15bc8d5764ab12cf6fc202fd9e7d36294b: No JIRA Issue found in commit message.
remote:
To REPONAME
 ! [remote rejected]   feature/OMT-1270-Missing-French-Translations -> feature/OMT-1270-Missing-French-Translations (pre-receive hook declined)
error: failed to push some refs to REPONAME

I've done this before and it's worked just fine. The ticket is also valid. Why does it keep throwing this error?

The repo is bitBucket and the original commit message was

git commit -m "OMT-1270 Adding missing translations"
like image 663
Haq.H Avatar asked Apr 20 '18 14:04

Haq.H


People also ask

Why pre-receive Hook declined?

The git "pre-receive hook declined" error is a common error that developers can encounter while using a git hosting service like Gitlab, Github, or BitBucket. In most cases, this error happens because the developer lacks the permission to push to a specific branch.

How do I remove pre received Hook declined?

This can be fixed by doing git pull first from the "eyk" remote or checking with any other user who might have pushed before you. Very large files were added to commit or some other change in the code that triggered the decline rules.

How do I fix commit message?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.

What is pre-receive hook?

Pre-receive hooks enforce rules for contributions before commits may be pushed to a repository. Pre-receive hooks run tests on code pushed to a repository to ensure contributions meet repository or organization policy. If the commit contents pass the tests, the push will be accepted into the repository.


1 Answers

Few organization enables the pre-hook to commit any content to the repository. Whenever you forget to put the JIRA number in the commit message, you need to amend the commit.

Here are the Steps to resolve:-

1)Navigate to the repository directory location using the "Git Bash"

2) Then do the rebase using "git rebase -i"

3) It gives a page showing your previous commits.

4) Click on "i" on keyword to get the edit mode .

5) Whichever commits you want to modify, change the word from "pick to edit"

6) Click on Escape to stop editing. Then type ":wq!" to save and exit

7) Now its time to amend the commit one by one using "git commit --amend"

8) Edit the commit message , adding your jira number.

9) Click on Escape to stop editing. Then type ":wq!" to save and exit

10) Repeat the 7,8,9 steps for the commits, you have chosen edit instead of pick. No need to repeat, if you are editing only one commit.

11) Once done for all, do "git rebase --continue"

12) Finally do "git push"

# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
like image 162
Sireesh Yarlagadda Avatar answered Sep 22 '22 08:09

Sireesh Yarlagadda