CLion 2021.1 Help

Contribute to projects on GitHub

If you want to contribute to a project that is hosted on GitHub and that you cannot push to directly, follow this workflow:

  • Create a fork of the project you want to contribute to.

  • Clone this fork to create a local repository.

  • Make changes to your copy of the original project, commit and push them.

  • When you are ready to share the results of your work, rebase your fork on the current HEAD of the master branch in the original project. This is needed to make sure your changes do not conflict with new commits that were pushed after you created your fork.

  • Create a pull request to suggest your changes to the original project.

Fork a project

A fork is your copy of a GitHub repository that allows you to make changes to code without affecting the original project.

Create a fork

  • Open the project that you want to fork on GitHub and click fork icon

A copy of the original project will be created under your account. To make changes to this project, you need to clone it to create a local repository.

Rebase a fork

  • From the main menu, choose Git | GitHub | Sync Fork. Your fork will be rebased onto the HEAD commit in the master branch of the original project you created your fork from.

Watch this video tutorial on how to keep your fork of a project up to date:

Create a pull request

Pull requests are used in open-source projects or in some corporate workflows to manage changes from contributors and to initiate code review before such changes are merged.

By creating a pull request, you tell others about the changes you've pushed to your fork of a GitHub repository, so that the maintainers of the original repository can review your changes, discuss them, and integrate them into the base branch.

  1. From the main menu, choose Git | GitHub | Create Pull Request. The Create Pull Request dialog opens.

  2. Under Base Fork, specify the project that you want to send the pull request to. Either select a repository from the list populated by CLion, or click Select Other Fork.

  3. Under Base Branch, specify the branch in the target project that your changes will be applied to. Click Show Diff to review the list of commits that will be included in the pull request. To view the details of a commit, select it and switch to the Log tab of the Version Control tool window Alt+9, where you can see a list of files included in the selected commit, view diff, and so on.

  4. Specify the name for your pull request in the Title field, and, optionally, provide a description of the changes to be applied through your request.

Manage incoming pull requests

If you're a project maintainer and you have a GitHub remote configured for your project, you can view incoming pull requests directly from CLion: from the main menu select Git | GitHub | View Pull Requests.

GitHub Pull Requests wool window

Use the GitHub Pull Requests tool window to:

  • Filter requests by state, author, assignee, and date.

  • Jump to a pull request on GitHub: select a pull request and choose Open on GitHub from the context menu.

  • View diff between the suggested changes and the base revision: select a file in the right pane and press Ctrl+D or click diff icon.

  • Create a local branch based on incoming changes: select a pull request and choose Create New Local Branch from the context menu.

Last modified: 30 March 2021