JetBrains Rider 2020.2 Help

Set up a Git repository

When you clone an existing Git repository, or put an existing project under Git version control, JetBrains Rider automatically detects if Git is installed on your computer. If the IDE can't locate a Git executable, it suggests downloading it.

JetBrains Rider supports Git from the Windows Subsystem for Linux 2 (WSL2), which is available in Windows 10 version 2004.

If Git is not installed on Windows, JetBrains Rider searches for Git in WSL and uses it from there. Also, JetBrains Rider automatically switches to Git from WSL for projects that are opened when you use the \wsl$ path.

If for some reason you need to manually configure JetBrains Rider to use Git from WSL, in the Settings/Preferences dialog Ctrl+Alt+S go to Version Control | Git, click the Browse icon in the Path to Git executable field and select Git from WSL via the \wsl$ path, for example, \\wsl$\debian\usr\bin\git.

Check out a project from a remote host (clone)

JetBrains Rider allows you to check out (in Git terms clone) an existing repository and create a new project based on the data you've downloaded.

  1. From the main menu, select VCS | Get from Version Control, or, if no project is currently opened, click Get from Version Control on the Welcome screen.

  2. In the Get from Version Control dialog, specify the URL of the remote repository you want to clone, or select one of the VCS hosting services on the left.

    If you are already logged in to the selected hosting service, completion will suggest the list of available repositories that you can clone.

  3. Click Clone. If you want to create a project based on the sources you have cloned, click Yes in the confirmation dialog. Git root mapping will be automatically set to the project root directory.

    If your project contains submodules, they will also be cloned and automatically registered as project roots.

Put an existing project under Git version control

You can create a local Git repository based on an existing solution sources.

Associate the entire project with a single Git repository

  1. Open the solution that you want to put under Git.

  2. Choose Enable Version Control Integration from the VCS Operations Popup Alt+` or from the main VCS menu.

  3. Choose Git as the version control system and click OK.

    JetBrains Rider: Enabling Git integration

  4. After VCS integration is enabled, JetBrains Rider will ask you whether you want to share project settings files via VCS. You can choose Always Add to synchronize project settings with other repository users who work with JetBrains Rider.

    Notification prompting to select how to treat configuration files

    For more information, see Share directory-based settings.

Associate different directories within the solution with different Git repositories

  1. Open the solution that you want to put under Git.

  2. From the main menu, choose VCS | Import into Version Control | Create Git Repository.

  3. In the dialog that opens, specify the directory where a new Git repository will be created.

    Git does not support external paths, so if you choose a directory that is outside your project root, make sure that the folder where the repository is going to be created also contains the project root.

  4. If you are creating multiple Git repositories inside the solution structure, repeat the previous steps for each directory.

After you have initialized a Git repository for your solution, you need to add solution files to the repository.

Add files to the local repository

  1. In the Local Changes view, expand the Unversioned Files node.
  2. Select the files you want to add to Git or the entire changelist and press Ctrl+Alt+A or choose Add to VCS from the context menu.

    You can also add files to your local Git repository from the Solution Explorer: select the files you want to add, and press Ctrl+Alt+A or choose Git | Add from the context menu.

When Git integration is enabled in your solution, JetBrains Rider suggests adding each newly created file under Git, even if it was added from outside JetBrains Rider. You can change this behavior in the Settings/Preferences dialog Ctrl+Alt+S under Version Control | Confirmation. If you want certain files to always remain unversioned, you can ignore them.

Exclude files from version control (ignore)

Sometimes you may need to leave certain files unversioned. These can be VCS administration files, artifacts of utilities, backup copies, and so on. You can ignore files through JetBrains Rider, and the IDE will not suggest adding them to Git and will highlight them as ignored.

You can only ignore unversioned files, that is files that you see in the Unversioned Files changelist. If a file is added to Git but not committed, you can right-click it in the and choose Rollback.

Git lets you list ignored file patterns in two kinds of configuration files:

  • .git/info/exclude file.
    Patterns listed in this file only apply to the local copy of the repository.

    This file is created automatically when you initialize or check out a Git repository.

  • One or more .gitignore files in the VCS root directory and its subdirectories.
    These files are checked into the repository so that the ignore patterns in them are available to the entire team. Therefore, it is a most common place to store the ignored file patterns.

    If there is no .gitignore file in the VCS root directory, you can switch the Explorer window to the File System view, right-click the root node , choose Add | File and type .gitignore in the New File dialog.

    JetBrains Rider: .gitignore in the project root

Add files to .gitignore or .git/info/exclude

  1. Decide what kind of Git configuration file you are going to use to ignore files. If in doubt, use .gitignore.

  2. Locate the unversioned file or folder you want to ignore in the or in Solution Explorer. File colors in these views help you identify the status of the file.

  3. Right click the selection and choose Git | Add to .gitignore or Git | Add to .git/info/exclude.
    File colors in these views help you identify the status of the file.

    JetBrains Rider: adding files to .gitignore

If you need to exclude files by a certain pattern, or files of a certain type, you can edit the .gitignore or .git/info/exclude file directly. See .gitignore patterns format

Check project status

JetBrains Rider allows you to check the status of your local working copy compared to the repository version of the project. It uses specific colors to let you see which files have been modified, which new files have been added to the VCS, and which files are not being tracked by Git.

Open the Local Changes view. Open the Commit tool window .

  • The Default changelist shows all files that have been modified since you last synchronized with the remote repository (highlighted in blue), and all new files that have been added to the VCS but have not been committed yet (highlighted in green).

  • The Unversioned Files changelist shows all files that have been added to your project, but that are not being tracked by Git.

For more info on changelists, see Group changes into different changelists.

Track changes to a file in the editor

You can also track changes to a file as you modify it in the editor. All changes are highlighted with change markers that appear in the gutter next to the modified lines, and show the type of changes introduced since you last synchronized with the repository. When you commit changes to the repository, change markers disappear.

The changes you introduce to the text are color-coded:

  • marker for a newly added line line added.

  • marker for a modified line line changed.

When you delete a line, the following marker appears in the gutter: the deleted line marker.

You can manage changes using a toolbar that appears when you hover the mouse cursor over a change marker and then click it. The toolbar is displayed together with a frame showing the previous contents of the modified line:

the modified line marker

You can roll back changes by clicking the Revert icon and explore the differences between the current and the repository version of the current line by clicking the Show diff icon.

Instead of reverting the whole file, you can copy any part of the contents of this popup and paste it into the editor.

Add a remote repository

To be able to collaborate on your Git project, you need to configure remote repositories that you fetch data from and push to when you need to share your work.

If you have cloned a remote Git repository, for example from GitHub, the remote is configured automatically and you do not have to specify it when you want to synchronize with it (in other words, when you perform a pull or a push operation). The default name Git gives to the remote you've cloned from is origin.

However, if you created a Git repository based on local sources, you need to add a remote repository for other contributors to be able to push their changes to it, and for you to be able to share the results of your work.

Define a remote

  1. Create an empty repository on any Git hosting, such as Bitbucket or GitHub.

  2. Invoke the Push dialog when you are ready to push your commits by selecting VCS | Git | Push from the main menu, or press Ctrl+Shift+K.

  3. In the dialog that opens, specify the remote name and the URL where it will be hosted, and click OK.

In some cases, you also need to add a second remote repository. This may be useful, for example, if you have cloned a repository that you do not have write access to, and you are going to push changes to your own fork of the original project. Another common scenario is that you have cloned your own repository that is somebody else's project fork, and you need to synchronize with the original project and fetch changes from it.

Add a second remote

  1. From the main menu, choose VCS | Git | Remotes. The Git Remotes dialog will open.

  2. Click the Add add button on the toolbar or press Alt+Insert.

  3. In the dialog that opens, specify the remote name and URL and click OK.


To edit a remote (for example, to change the name of the original project that you have cloned), select it in the Git Remotes dialog and click the Edit edit button on the toolbar, or press Enter.

To remove a repository that is no longer valid, select it in the Git Remotes dialog and click the Remove remove button on the toolbar, or press Alt+Delete.

Learn more from this video:

Last modified: 29 October 2020