Git & GitHub ยท Chapter 33 of 42

GitHub Issues

GitHub Issues are used to track bugs, feature requests, and tasks for a repository. Each issue has a title, description, labels, assignees, and a discussion thread.

Issues can be linked to pull requests and commits, so closing a pull request can automatically close the related issue, keeping project tracking organized.

Syntax
git commit -m "Fix login bug, Fixes #42"

Creating and managing issues

Click 'New issue' on a GitHub repo, give it a clear title and description, and optionally add labels (like 'bug' or 'enhancement') and assign it to a team member.

Linking issues to commits and PRs

Reference an issue number like #42 in a commit message or pull request description. Using keywords like 'Fixes #42' automatically closes the issue when the PR merges.

Example 1 (bash)
git commit -m "Fix null pointer on empty cart, fixes #17"
Output
[main 5a1c9de] Fix null pointer on empty cart, fixes #17

References issue #17 in the commit message so GitHub can link the fix to the issue.

Example 2 (bash)
git push origin main
Output
To github.com:user/repo.git
   7f3c2ee..5a1c9de  main -> main

Pushing this commit (once merged via PR) will automatically close issue #17 on GitHub.

Key points

  • Issues track bugs, features, and tasks in a repository.
  • Issues support labels, assignees, and discussion threads.
  • Referencing 'Fixes #number' links commits/PRs to issues.
  • Merging a linked PR can automatically close the related issue.
๐Ÿ’ก Note: Labels like 'bug', 'good first issue', and 'help wanted' make it easier for contributors to find relevant issues.

๐Ÿ“ Quick Quiz

1. What are GitHub Issues used for?

2. What keyword in a commit message can auto-close an issue?

3. What can be attached to a GitHub issue?