# How to Automatically Close GitHub Issues Using Commit Message Keywords

> Automate closing GitHub issues with commit message keywords like fix close or resolve and an issue number. Streamline your workflow and improve repository management.

- Repository: [Tim Green/github-cheat-sheet](https://github.com/tiimgreen/github-cheat-sheet)
- Tags: how-to-guide
- Published: 2026-03-06

---

**GitHub automatically closes issues when commits containing the keywords `fix`, `close`, or `resolve` (along with their variants) followed by an issue reference like `#12` are merged or pushed to the repository's default branch.**

The tiimgreen/github-cheat-sheet repository documents this automation feature in its [`README.md`](https://github.com/tiimgreen/github-cheat-sheet/blob/main/README.md) file, providing developers with a streamlined workflow for linking code changes to issue resolution. By incorporating specific trigger words into your commit messages, you can eliminate the manual step of closing issues after merging fixes, ensuring project tracking stays synchronized with your codebase.

## Supported Closing Keywords

GitHub recognizes three groups of keywords that trigger automatic issue closure. According to the source documentation in [`README.md`](https://github.com/tiimgreen/github-cheat-sheet/blob/main/README.md), these keywords are **case-insensitive** but must match the exact spelling:

- **fix**, **fixes**, **fixed**
- **close**, **closes**, **closed**
- **resolve**, **resolves**, **resolved**

Each keyword must be immediately followed by the issue number prefixed with a hash symbol (e.g., `#27`). Variations like `fixing` or `closedd` will not trigger the automation.

## How the Auto-Close Mechanism Works

When you push commits to your repository, GitHub scans the commit messages for these specific patterns. The process follows a strict sequence:

1. **Write the commit message** including a supported keyword and the issue reference in the format `keyword #number`.
2. **Push to the default branch** (typically `main` or `master`). The automation only triggers when commits land on the repository's default branch.
3. **GitHub processes the reference** and automatically marks the issue as **Closed**, adding a reference to the specific commit in the issue's timeline.

## Writing Effective Commit Messages

To implement this feature in your workflow, structure your commit messages to include the closing reference. The `github-cheat-sheet` repository provides several practical patterns in its documentation.

Close a single issue while fixing a bug:

```bash
git commit -m "Fix typo in login flow, closes #27"

```

Amend an existing commit to add a closing reference you forgot:

```bash
git commit --amend -m "Refactor auth module, resolves #42"

```

Close multiple issues with one comprehensive commit:

```bash
git commit -m "Add new API endpoint, fixes #58, closes #59, resolves #60"

```

After writing the commit, push to your default branch:

```bash
git push origin main

```

## Critical Rules and Limitations

The automatic closure feature operates under specific constraints documented in the repository's [`README.md`](https://github.com/tiimgreen/github-cheat-sheet/blob/main/README.md) section on closing issues.

**Commit Message Placement:** The keyword must appear in the **commit message body**, not exclusively in the subject line. While the subject can contain the reference, the parsing mechanism requires the keyword-issue pattern to be present in the full commit message text.

**Default Branch Only:** Commits pushed to feature branches, pull request branches, or non-default branches will not trigger issue closure until they are merged into the default branch (usually `main` or `master`).

**Issue Reference Format:** You must use the hash prefix (`#`) followed immediately by the issue number. References like `issue 12` or `number 12` will not trigger the automation.

## Summary

- GitHub supports nine closing keywords across three root words: **fix**, **close**, and **resolve**, including their past-tense and plural forms.
- The keyword must be followed immediately by `#<issue_number>` and can be placed anywhere in the commit message body.
- Automatic closure only occurs when commits reach the repository's **default branch**, not when pushed to feature branches.
- Multiple issues can be closed simultaneously by listing multiple keyword-issue pairs in a single commit message.
- This feature is documented in the [`README.md`](https://github.com/tiimgreen/github-cheat-sheet/blob/main/README.md) file of the tiimgreen/github-cheat-sheet repository under the "Closing Issues via Commit Messages" section.

## Frequently Asked Questions

### Does capitalization affect the closing keywords?

No, GitHub processes these keywords case-insensitively. Whether you write `Closes #12`, `CLOSES #12`, or `closes #12`, the automation will trigger identically. However, the spelling must match exactly—variations like `closing` or `fixeds` are not recognized.

### Can I close multiple issues with a single commit?

Yes, you can reference and close multiple issues in one commit message by separating each keyword-issue pair with commas or spaces. For example: `git commit -m "Update dependencies, fixes #10, resolves #11, closes #12"`. Each referenced issue will be closed when the commit reaches the default branch.

### Why didn't my issue close after pushing the commit?

The most common reason is that the commit was pushed to a feature branch rather than the **default branch**. Automatic closure only occurs when commits land on the repository's default branch (usually `main` or `master`). Additionally, ensure the keyword appears in the commit message body and that the issue number includes the `#` prefix.

### Can I use these keywords in pull request titles instead of commit messages?

The tiimgreen/github-cheat-sheet documentation specifically describes this mechanism for **commit messages** that land on the default branch. While pull request descriptions and titles can also reference issues, the canonical implementation documented in the source requires the keywords to be present in commit messages that are merged or pushed to the default branch.