Getting the JIRA issue ID with project key using commits done to a branch

Hi I am looking for a solution where I could get the JIRA issue id using the commits done to a branch. In jira when an issue is assigned ideally we create a branch from the same issue id but as we commit to the branch and later view the commits done to a branch I am unable to retrieve the jira issue id assoicated with the commit ? Any suggestions how to achieve such kind of linking ?