Resolve issues automatically when users push code

You can configure Bitbucket Cloud to resolve tickets automatically when people push updates through to your Bitbucket Cloud repository.  Users specify commands and issues in a commit message, for example:

hg commit -m "fixes #6, resolve ticket #5 and see ticket #9 and ticket #5 in the tracker"

On Bitbucket, the commit message appears with links to each issue:

When you transition an issue with a commit message, the system cross-references the commit from the issue:

If you enabled an issue tracker on your repository after August 2012, Bitbucket adds the Issues hook automatically for you when you enable the Issue Tracker.  Older repositories with older issue trackers may or may not have this hook.  You can check if this hook exists for a repository by going to the Hooks tab in the repository settings:

Adding the Issue Hook Manually

You only need to perform this procedure if your repository has an issue tracker enabled but does not have an Issue issue on the repository. You must have administrative access on a repository to add this hook.

  1. Go to the repository's settings.
  2. Click Hooks in the left-hand navigation.
    The hook page appears.
  3. Select the Issues hook from the Hook dropdown.
  4. Click Add hook.
    A new section appears for the Issues hook.

  5. Press Save.
    The page remains unchanged but the hook is started.

Including Issues in a Commit Message

To link commit to an issue from a commit message, include an command-issue pair somewhere in your commit message. This pair takes the following format:

<command> <issue id>

You can link to a single issue or multiple issues.  The <issue id> can take an of the following forms:

issue #4711
bug #4711
ticket #4711

You should always include the # (pound sign or hash mark) if you to ensure that links back to the issue resolve.  If you omit the # (pound sign or hash mark), links from a changeset do not resolve.

Each action supports multiple <command> keywords. The following table lists the actions you can perform through a commit and the acceptable commands for that action.  All the keywords are case insensitive. So, for example, both close and Close work to close an issue.

Action Command Keyword Examples
resolve an issue
  • close
  • closes
  • closed
  • closing
  • fix
  • fixed
  • fixes
  • fixing
  • resolve
  • resolves
  • resolved
  • resolving

close #845

fix bug #89

fixes issue 746

resolving #3117
reopen an issue
  • reopen
  • reopens
  • reopening
reopen #746

reopening #78

mark an issue on hold
  • hold
  • holds
  • holding
holds #123
mark an issue wontfix
  • wontfix
wontfix #12
mark an issue invalid
  • invalidate
  • invalidates
  • invalidated
  • invalidating
invalidates #45
link to a changeset for the issue
  • addresses
  • re
  • references
  • ref
  • refs
  • see
re bug #55

see #34 and #456

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

21 Archived comments

  1. User avatar


    cool feature

    30 Oct 2012
  2. User avatar



    01 Nov 2012
  3. User avatar

    Greg Bruening

    Perhaps I'm doing something weird with my commits but resolving issues via commit seems incredibly unreliable.

    50% of the time, "close #" will function as intended but the other 50% it will just never close the item. Is there a time delay in how long it takes BB to register that I said to close the issue? If I open the commit, I can see the "close #" and can click on the issue number, but it will never close.

    The same goes for the accepted terminology - it's been a guessing game lately. "close" works but "closes" didn't, "resolve" worked once, but "Resolving" didn't. I'm one that likes to tack these at the end of my explanation (ie, "Changed all widths of module content to 270px, resolving #34") so is the extra text or the fact that I have multi-line commits causing issues? I'm trying to integrate the Issue Tracker into our every day dev but these unknowns (what terms work vs don't, is it finicky, do line breaks matter) make it hard to dive in fully.

    As an addendum, I use Tower for my Git - could this be a potential reason for the unreliability?

    16 Sep 2013
    1. User avatar


      Greg, It could be your Git.  I would suggest you file a support ticket next time you see this.  Apologies for the slow reply, I've had a ton of non-BB work to do lately.

      02 Oct 2013
      1. User avatar

        Greg Bruening

        Perfectly alright - I've found (since then) that putting all of your "close, resolve, etc" terms as the first line of your commit changes the efficiency to 100%. It just seems to struggle if you try putting them further down in sentences, etc.

        I'll try and think of an intelligent way to make an issue as I haven't tested the exact details and no one else seems to suffer from this (tongue)

        02 Oct 2013
  4. User avatar


    I'd like to create new JIRA issues from bitbucket commenting also. Could the same hook be applied against comments?

    07 Oct 2013
    1. User avatar


      You can file an enhancement request for this feature.

      07 Oct 2013
  5. User avatar

    Casper Schmidt Wandahl-Liper

    I just made a commit fixing an issue (type=enhancement). I used the message "Fixes enhancement #18" for my commit, but the issue was not marked as resolved? All the other issues I have resolved had a commit message like "Fixes bug #9" and this works fine - marking the issue as resolved.

    28 Nov 2013
    1. User avatar


      It only works if you have Fixes #… but with a word in between the parser doesn't recognize the 'Fixed' pattern.

      28 Nov 2013
      1. User avatar

        Casper Schmidt Wandahl-Liper

        The table doesn't say what the parser recognizes or not. It simply says you can use one of the keywords (fx. "fixes" or "fixed") and then it gives a list of EXAMPLES. Given the different types of issues in BitBucket I would think the parser would recognize any of them, otherwise the table above should state excactly which issue types can be resolved using which commands.

        29 Nov 2013
        1. User avatar

          Richard Fox

          Hi, Just thought i'd clarify this for other users browsing the documentation.

          The Examples clearly state

          <command> <issue id>

          as the format and not

          <command> <issue type> <issue id>.

          Therefore types are not supported.

          They also do not need to be supported as each ID regardless of it's type has a unique ID.

          The first issue created is always #1 and then #2 etc. Regardless of type.

          05 Feb 2015
  6. User avatar

    Adam Grey

    How often does it actually run? I use JIRA with bitbucket, and it seems that JIRA issues only get updated once a day.


    Or does JIRA perhaps only collect commits over a certain amount of time?

    30 Nov 2013
  7. User avatar


    First time on git and code versioning ... Never thought of coding such an easy and organized way (smile) 
    I wish I could grab it when I learnt coding...! 

    10 Feb 2014
  8. User avatar

    Julien Bessede

    Is there a keyword also to assign an issue to someone directly in the bitbucket comments or commits ?

    Something like "assign @Julien #issue 123"

    10 Feb 2014
  9. User avatar

    Peter Bigot

    This isn't quite as useful as it could be, since issues are updated as soon as the commit appears in the repository, even if it's in a development branch.  Rebasing development branches produces repeated issue comments, leaving traces to material that is no longer relevant.  This would be more useful if it could be restricted to apply only to commits appearing on certain branches, such as master.

    19 Dec 2014
    1. User avatar

      Richard Fox

      If you need to rebase and potentially squash or cherry pick commits then your fixes message should appear on the final result and not the actual developers commit.

      So instead of "Updated code, fixes #123"

      It would be "Merged branch fix-123 into master, fixes #123'

      05 Feb 2015
  10. User avatar

    Kaz Nishimura

    What happens if the commits are pulled to a forked repository?  Should I disable the automatic issue management hook on a forked repository?

    01 Jan 2015
  11. User avatar

    Kathleen Newman

    I have been trying for eons to add a custom drop down menu with html code and even script to pages but Confluence does not seem to activate the code? Is this a setting on the server that needs to be initialized or what? Is it a setting in Confluence itself?

    I want to be able to add any type of code I want to in pages. Why is this not working?  For example:

    <div class="aui-navgroup aui-navgroup-horizontal"> 

    <div class="aui-navgroup-inner">    

    <div class="aui-navgroup-primary">      

    <ul class="aui-nav">        

    <ul class="aui-nav">          


    <a href="#">Nav item</a>          

    </li>           <li class="aui-nav-selected">             <a href="#">Selected item</a>           </li>           <li>             <a href="#">Pull Requests <span class="aui-badge">123</span> </a>           </li>           <li>             <a class="aui-dropdown2-trigger" href="#dropdown2-nav1">Dropdown <span class="aui-icon-dropdown"> </span> </a>           </li>           <li>             <a href="#"> <span class="aui-icon aui-icon-test16-dark"> </span> Overview</a>           </li>           <li>             <a href="#">Kitchen Sink</a>           </li>         </ul>       </ul>       <div class="aui-navgroup-secondary">         <ul class="aui-nav">           <li>             <a class="aui-dropdown2-trigger" href="#dropdown2-nav1"> <span class="aui-icon aui-icon-small aui-iconfont-configure">Configure</span> </a>           </li>         </ul>       </div>     </div>

    20 Jan 2015
    1. User avatar

      Dan Stevens [Atlassian]

      Hello Kathleen,

      I think you want to post this in Confluence Documentation Home you might find what you need here: HTML Macro.

      Hope this helps. Happy coding (or writing as the case may be),


      20 Jan 2015
  12. User avatar

    Justin Villocido

    I have an issue with using git commit -m "fix issue #2". We just changed ownership of a Bitbucket repository and made corresponding reconfiguration on our locals. What I noticed on the "issues" is that they are renumbered back to 1. With the reconfiguration, I can successfully add commits and push them to bitbucket. Now, the problem is that issues are not marked as fixed with the "git commit -m fixes..." command.

    24 Mar 2015
  13. User avatar

    Radu Cruceru

    I'm probably a little late to the party, but I haven't figured yet what command should I include so that an issue is closed AFTER the pull request is accepted and the branch is merged. 

    It just makes more sense to me to mark an issue as fixed AFTER the code is merged in master branch. Don't you think?

    It happened a few times to look at the list of issues and be jolly that some weird bugs we're fixed, just to find out that pull requests still existed.

    13 Aug 2015
Powered by Confluence and Scroll Viewport