Git Error: missing a valid issue key

One of your commit messages is missing a valid issue key

I just thought I would share with you how to fix this really annoying git error. So you have updated your code, completed a git add, adding a git commit messages and then pushed the code – now you get this message!

Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 10 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 865 bytes | 865.00 KiB/s, done.
Total 9 (delta 6), reused 0 (delta 0), pack-reused 0
remote: 
remote: One of your commit messages is missing a valid issue key:
remote: 
remote:   cbfb6e6: feature/dhi-1490:added inbound rules
remote: 
remote: For more information, see https://support.atlassian.com/bitbucket-cloud/docs/link-to-a-web-service/
To bitbucket.org:ShopDirect/ds-terraform-pbi-infrastructure.git
 ! [remote rejected] feature/dhi-1490-Add-RDP-Inbound -> feature/dhi-1490-Add-RDP-Inbound (pre-receive hook declined)
error: failed to push some refs to 'bitbucket.org:{MY_PRIVATE_REPO}/{MY_PRIVATE_REPO}infrastructure.git'

Discrepancies in repo rules cause this error. You can see what your rules are by viewing your repository settings. I use bitbucket so its in Repo > Settings > Repository Links

If you don’t have access to this part of the repo, the easiest thing to do is check previous commit logs to see how everyone else has written their commit message.

Step 1 – View the Git Log.

View the previous git commits and look for the problem. My issue was that i had a rule that required the JIRA ticket to be in UPPER case, my initial commit was in lower case. I worked this out by reviewing other commit messages in the log.

git log

For Example:

commit bd2846e70c417d9de4e1dcca763ddbb85328b14d (HEAD -> feature/dhi-1490-Add-RDP-Inbound, origin/feature/dhi-1490-Add-RDP-Inbound)
Author: Richard Bailey <[email protected]>
Date:   Thu Sep 29 13:56:31 2022 +0100

    feature/dhi-1490:added inbound rules

commit b48f4960a85dc24c840c00e822752917ebbe07b9 (origin/master, origin/HEAD, master)
Merge: a982cdc 378c1db
Author: Colleague 1 <[email protected]>
Date:   Wed Aug 3 10:13:57 2022 +0000

    Merged in feature/DHI-1119 (pull request #55)
    
    Feature/DHI-1119
    
    Approved-by: Colleague3
    Approved-by: Colleague4

If you compare the above you will see that my commit bd2846e70c417d9de4e1dcca763ddbb85328b14d was written in lower case, but commit b48f4960a85dc24c840c00e822752917ebbe07b9 was in upper.

Step 2 – Soft Reset the Git Header.

git reset --soft HEAD~1 

Step 3 – Proceed to Recommit Your Work

git add .
commit -a -m'Feature/DHI-1490-my-commit-message'
git push

The code should now commit.

Elsewhere On TurboGeek:  How to manage Terraform State

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

1 Response

  1. Subramaniam says:

    This works perfect and flawless. I tried so many options given in stack overflow and other sites and nothing worked for me except your suggestion.
    Thank you lot.

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป