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.

Runner H image

Runner H Viral Content Factory Agent

Check out this winning submission to the Runner H "AI Agent Prompting" Challenge. 👀

Read more →

Top comments (0)

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

👋 Kindness is contagious

Explore this practical breakdown on DEV’s open platform, where developers from every background come together to push boundaries. No matter your experience, your viewpoint enriches the conversation.

Dropping a simple “thank you” or question in the comments goes a long way in supporting authors—your feedback helps ideas evolve.

At DEV, shared discovery drives progress and builds lasting bonds. If this post resonated, a quick nod of appreciation can make all the difference.

Okay