8

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"
Haq.H
  • 863
  • 7
  • 20
  • 47
  • "the repo" is something your office has set up, presumably, and we need _much_ more context to help. Like what system is actually rejecting your pre-receive hook, BitBucket, BitBucket Server (aka Stash), GitLab? That's where the _actual problem is._ – msanford Apr 20 '18 at 14:28
  • 1
    I was going to say, we probably need to see the commit message as well. – dimwittedanimal Apr 20 '18 at 14:30
  • Yeah, you haven't by chance confused "branch name" with "commit message", or have a typo in your message with a correct branch name? If that's your problem, [**this** will answer the next question you're about to ask](https://help.github.com/articles/changing-a-commit-message/). – msanford Apr 20 '18 at 14:31
  • ah I apologize for the vagueness I'll edit the original question! Also I don't think the issue is with BItBucket but my local clone. I cloned another instance and I can push just fine from that one. – Haq.H Apr 20 '18 at 16:09
  • @Haq.H As a sidenote, to automate a bit the process of prepending commit messages with issue numbers / branch names, you can rely on [hooks](https://stackoverflow.com/a/54078057/1057485). – Romain Valeri Feb 02 '19 at 02:39

1 Answers1

15

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
Sireesh Yarlagadda
  • 12,978
  • 3
  • 74
  • 76