Collaboration on GitHub

This page introduces key GitHub features for collaboration, including forking vs cloning, issues, pull requests, labeling issues/PRs, and more. These tools help streamline collaboration and code review in open source and team projects.

Forking vs Cloning

GitHub provides two ways to work with repositories: forking and cloning.

  • Forking: Creates a copy of someone else’s repository under your GitHub account. You can modify this copy and later propose changes to the original repository via a pull request (PR).

  • Cloning: Downloads a local copy of a repository on your machine so you can work on it. You can clone both your own and other users' repositories (public repositories).

Forking a Repository

Forking a Repository
Figure 1. Forking a Repository

To fork a repository:

  1. Navigate to the repository on GitHub.

  2. Click the Fork button in the upper-right corner.

  3. Choose the location (your account) to create the fork.

After forking, you can clone it to your local machine:

$ git clone https://github.com/<your-username>/<repository-name>.git

Cloning a Repository

Cloning a Repository
Figure 2. Cloning a Repository

To clone a repository (without forking):

$ git clone https://github.com/<username>/<repository-name>.git

Replace <username> with the repository owner’s username.

in VS Code, to clone a repository, you can use the Git: Clone command from the command palette Ctrl+Shift+P on Linux, see VSCode Basic Cheatsheet and provide the repository URL.

Issues

Issue Tab
Figure 3. Issue Tab

GitHub Issues provide a way to track bugs, feature requests, and tasks for a project. Each issue has its own discussion thread, and developers can assign issues, add labels, and link them to pull requests.

Create a New Issue
Figure 4. Create a New Issue

To create a new issue:

  1. Navigate to the repository.

  2. Click on the Issues tab.

  3. Click New issue and provide a title and description.

Closing Issues with Commits

You can close an issue automatically by mentioning it in your commit message:

$ git commit -m "Fixes #123 - Update the login functionality"
$ git push origin main

This will automatically close issue 123 when the commit is pushed thanks to the keyword Fixes and then the issue number prefixed by . Similar keywords include Closes, Resolves, and Addresses.

How to write issues ?
For guidelines about how to write issues, please refer to How to Write a GitHub Issue.

Pull Requests (PRs)

A pull request (PR) proposes changes from your branch to the main repository. Other contributors can review the PR, discuss changes, and eventually merge it.

Creating a PR

Create a PR
Figure 5. Create a New PR

To create a PR after pushing your changes:

  1. Go to the repository on GitHub.

  2. Click on the Pull requests tab.

  3. Click New pull request, select your branch, and create the PR.

You can also reference issues related to the PR by mentioning them (e.g., #123).

PR from a Fork

If you forked a repository and made changes, you can submit a pull request to the original repository.

$ git push origin <branch-name>

After pushing your changes, create a PR from your fork’s repository to the original repository.

Collaborators

Repository owners can invite collaborators to work on private repositories. Collaborators have write access to the repository.

To add a collaborator:

  1. Navigate to the repository settings.

  2. Under the Manage access tab, invite the collaborator by their GitHub username.

Labelling Issues / PRs

Labels help organize and categorize issues and PRs. GitHub provides default labels like bug, enhancement, and question, but you can create custom labels.

To add labels to an issue or PR:

  1. Open the issue/PR.

  2. Click Labels on the right-hand side.

  3. Choose the labels to apply.

Saved Replies

Saved replies allow you to create and reuse common responses for issues and pull requests. This is useful for repeating instructions, responses, or comments.

To create a saved reply:

  1. Navigate to your profile settings.

  2. Under Saved replies, add a new reply template.

  3. Use it while commenting on issues or pull requests.

Mentions

Message Mention
Figure 6. Message Mention

To get someone’s attention in an issue or pull request, you can mention them using @ followed by their GitHub username. For example:

@octocat Can you review this PR?

This sends a notification to the mentioned user.

Reactions

Raction
Figure 7. Reaction

GitHub allows you to react to comments, issues, and pull requests with emojis such as 👍 (thumbs up) and ❤️ (heart). Reactions help gauge community feedback without adding comments.

To react to a comment:

  1. Hover over the comment.

  2. Click the smiley face icon and select a reaction.

Commenting

Comments
Figure 8. Comments

Comments can be added to issues, pull requests, and specific lines of code in a pull request diff. Comments are a key part of GitHub’s review and discussion process.

To comment on an issue or PR:

  1. Open the issue or Pull Request tabs.

  2. Scroll down to the comment box.

  3. Write your comment and click Comment.

For code review, you can leave line-by-line comments directly on the PR diff.

GitHub Discussions

Discussions
Figure 9. Discussions

GitHub Discussions is a feature that provides a space for long-form conversations separate from issues. Discussions are often used for community engagement, Q&A, and planning.

To create a discussion:

  1. Navigate to the Discussions tab of a repository.

  2. Click New Discussion and choose a category.

  3. Write your discussion topic and post it.

Discussions allow voting, threading, and marking answers as "solved."

A New Discussion
Figure 10. A New Discussion

After the discussion is created, community members can participate by replying, voting, or marking answers.

The discussions tab provides a nice way to engage with the community and gather feedback.

Discussion View
Figure 11. Discussion View

Summary

This guide covers various collaboration features on GitHub, including forking, cloning, issues, pull requests, saved replies, mentions, and GitHub Discussions. These tools enable effective collaboration and code management within open-source or team projects. Please check back the page > GitHub and Project Management for more information on project management.

For more information, check the official GitHub documentation: GitHub Docs.