DEV Community

Cover image for How to automatically close your issues once you merge a PR
Michelle Duke for GitHub

Posted on β€’ Edited on

24 4 3 5 3

How to automatically close your issues once you merge a PR

It's really annoying go through all your issues, and close each one once a feature request or bug report has been completed. The pull request gets merged and then you gotta go find the issue that it corresponds to... way too much time.

Now GitHub has given you a way to automatically close your issues once a pull request has been merged. Let me show you how.

Step 1. Create a pull request

Like you usually do, open your pull request as normal.

Go to your repository, make some changes and open a pull request, but don't click "Create pull request" yet:

Image description

Step 2. Tag the relevant issue

Before you click "Create pull request", we need to link the relevant issue to the pull request so that the correct issue is automatically closed.

    1. Write part of your commit message as usual:

Image description

    2. Add a "linking" keyword to your commit message:

Image description
You can see above here, I've used "closes" (underlined). There are several keywords you can use including:

  • close
  • closes
  • closed
  • fix
  • fixes
  • fixed
  • resolve
  • resolves
  • resolved
    3. Tag the relevant issue by typing `#` on your keyboard and selecting or typing in the number of the issue you want to link to:

Image description

Step 3. Merge and close your pull request

Now that you have all the necessary messages and tags, you can go ahead and merge the pull request as usual.

    1. Click "Merge pull request":

Image description

    2. You should see the message that your pull request has been successfully merged:

Image description

You can delete your branch now if you like.

Step 4. Issue is automatically closed

When you navigate back to the relevant issue, you'll see that it is now automatically closed:

Image description

You'll also see the pull request is mentioned in the issue history, and there's a message at the top which reads "Fixed by #96". This means the issue has been resolved by pull request number 96.

Automatically closing issues

I hope this short tutorial gives you a little more control and automation over your repositories on GitHub.

If you'd like to see this as a video, check out our YouTube Short:

There are also other ways you can automatically close issues. Read up on them all in the GitHub Docs.

πŸ‘‹ One new thing before you go

Not investing in your developer career? πŸ˜’

We have created a membership program that helps cap your costs so you can build and experiment for less. And we currently have early-bird pricing which makes it an even better value! πŸ₯

Just one of many great perks of being part of the network ❀️

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay