When you switch to a branch, JetBrains Rider automatically restores your context associated with that branch. JetBrains Rider saves your context (a set of opened files, the current run configuration, and breakpoints) provided that the Restore workspace on branch switching option is enabled in the Settings/Preferences dialog Ctrl+Alt+S under Version Control | Confirmation. If you want to clean your working copy using stash instead of shelve, go to the Version Control | Git page of the IDE settings Ctrl+Alt+S and choose Shelve under the Clean working tree using setting. If a conflict occurs during the unshelve operation, you will be prompted to merge the changes. If you click Smart Checkout, JetBrains Rider will shelve uncommitted changes, check out the selected branch, and then unshelve the changes.
If you click Force Checkout, your local uncommitted changes will be overwritten, and you will lose them. If your local changes are going to be overwritten by checkout, JetBrains Rider displays a list of files that prevent you from checking out the selected branch, and suggests choosing between Force Checkout and Smart Checkout. If your working tree is clean (that means you have no uncommitted changes), or your local changes do not conflict with the specified branch, this branch will be checked out (a notification will pop up in the bottom-right corner of the JetBrains Rider window). What happens next depends on whether there are conflicts between your local changes that you have not committed yet, and the branch that you are going to check out: In the Branches popup or in the Branches pane of the Git tool window, select the branch that you want to switch to under Local Branches and choose Checkout from the list of available operations. When multitasking, you often need to jump between branches to commit unrelated changes.
The new local branch will be set to track the origin remote branch. In the Branches popup or in the Branches pane of the Git tool window, select a branch that you want to check out locally from Remote Branches, or Common Remote Branches if your project has several roots and synchronous branch control is enabled, or from Repositories | Remote Branches if it is disabled.Ĭhoose Checkout from the list of actions.Įnter a new name for this branch if necessary, or leave the default name that corresponds to the remote branch, and click OK.
To make sure you have a full list of remote branches, click Fetch in the branches popup:
If you want to work on a branch created by someone else, you need to check it out to create a local copy of that branch. In the Log view, select the commit that you want to act as a starting point for the new branch and choose New Branch from the context menu.Ĭheck out branches (git-checkout) Check out a branch as a new local branch In the Branches popup or in the Branches pane of the Git tool window select a local or a remote branch that you want to start a new branch from and choose New Branch from Selected. The new branch will start from the current branch HEAD. In the dialog that opens, specify the branch name, and make sure the Checkout branch option is selected if you want to switch to that branch. In the Branches popup, choose New Branch or right-click the current branch in the Branches pane of the Git tool window tool window and choose New Branch. To hide non-favorite branches, click Show Only Favorites at the bottom of the Branches popup.Ĭreate new branch Create a new branch from current branch You can also select a branch in the Branches pane of the Git tool window and click on the toolbar. To mark a branch as a favorite, in the Branches popup, hover the mouse cursor over the branch name, and click the star outline that appears on the left: Favorite branches are always displayed at the top of the Branches popup and in the Branches pane of the Git tool window. The master branch is marked as a favorite by default. If you have many branches, you may want to see only your favorite ones. You can also manage branches and perform batch operations with multiple branches in the Branches pane of the Git tool window. In JetBrains Rider, all operations with branches are performed in the Git Branches popup: To invoke it, click the Git widget in the Status bar (it shows the name of the branch that is currently checked out):
In Git, branching is a powerful mechanism that allows you to diverge from the main development line, for example, when you need to work on a feature, or freeze a certain state of a code base for a release, and so on.