# Branch Management For Git Source Control

Test Studio supports management of Git branches in remote and local repositories.

## Remote Repository

Once a local project is connected to a remote Git repository or a remote project is opened and locally cloned in Test Studio its branches could be managed within Test Studio.

1. Open a source control project enabled for Git.

2. Remote repository supports **Commit**, **Push**, **Pull** and **Discard Local Changes**.

   ![Remote Available Options](https://www.telerik.com/teststudio/documentation/assets/c38392fb08dc1b0755939581abd2b6a6/fig2_remote_availableoptions.png)

3. The **Manage Branches** dialog could be accessed from the Project Explorer options menu or from the Source Control ribbon.

   ![Manage Branches Remote Repo](https://www.telerik.com/teststudio/documentation/assets/0d99164f74f1c2eec453b3f11ef64b6f/fig3_remote_managebranches.png)

4. The **Manage Branches** dialog contains a list of local and remote branches. The initially created branch is set as default one and is called master.

   ![Default Remote Branch](https://www.telerik.com/teststudio/documentation/assets/002103209f8a63c3db6c06d32ee09629/fig4_remote_defaultbranch.png)

5. In the **Manage Branches** dialog a new local branch could be created. Enabling the checkbox "Checkout after creation" will automatically checkout the newly created branch.

   ![Create Branch Remote Repo](https://www.telerik.com/teststudio/documentation/assets/957fddabf4f78dda614e05600107ce53/fig5_remote_createbranch.png)

6. The newly created local branch will appear in the respective list and will be marked as current with a red arrow sign in front of its name. Once the dialog is closed the project will be reloaded to display the new branch.

   ![New Branch Remote Repo](https://www.telerik.com/teststudio/documentation/assets/c99c48bad8b28956a8c740e5ffd1a2d6/fig6_remote_newbranch.png)

The current branch is also displayed in the **Source Control** ribbon.

![Current Branch](https://www.telerik.com/teststudio/documentation/assets/af78b3ac544f84db5cf8a4b88ffb0e76/fig7_currentbranch.png)

7. The newly created branch will remain local until it is pushed to the remote repository. To do so open the **Manage Branches** window, select the branch to push to remote repository and click the **Push** icon.

   ![Push New Branch To Remote Repo](https://www.telerik.com/teststudio/documentation/assets/d88eea723e5417c8e2b8ebffcc734926/fig6_remote_pushnewbranch.png)

8. The refresh button for the list with remote branches will fetch all references from the remote server and clear stale local ones.

   ![Refresh Remote List](https://www.telerik.com/teststudio/documentation/assets/7722a42f1ebac54f76a5260e0c30f8e6/fig8-refresh.png)

9. If there is a remote branch not present in the local project it could be checked out and a local branch with the same name will be created.

   ![Checkout Remote Branch](https://www.telerik.com/teststudio/documentation/assets/de346539f28995ccfef405102fd2013d/fig9-checkout-remote-branch.png)

Checkout a remote branch already existing in the local repository will checkout the local branch with the same name.

10. In the case when there are local commits not pushed to the remote branch the local one will be displayed in bold.

![Local Changes Not Pushed](https://www.telerik.com/teststudio/documentation/assets/9a839a8c8cb46e0173ec619dcb59139a/fig10-commited-locally.png)

11. In the case when there are remote commits not pulled to the local branch it will be displayed in italic.

![Remote Changes Not Pulled](https://www.telerik.com/teststudio/documentation/assets/26a8aa55ac634ce34c166ab334e2a4b5/fig11-commited-remotely.png)

12. Pull command could be executed against the current checked out branch only. Checkout is grayed out.

![Pull Command](https://www.telerik.com/teststudio/documentation/assets/194f36d1a6129ab442a35088c36acb8f/fig12-pull.png)

If a branch is not currently checked out the Checkout button is active and Pull is grayed out.

![Checkout](https://www.telerik.com/teststudio/documentation/assets/1341e9b0310983f21dc8110e82520380/fig13-deletel.png)

13. Both local and remote branches could be deleted. Since the change is irreversible there is a warning message to confirm your choice.

![Delete](https://www.telerik.com/teststudio/documentation/assets/1341e9b0310983f21dc8110e82520380/fig13-deletel.png)

## Local repository

A local project could be also source control enabled using Git and local branches could be maintaned in Test Studio.

1. Open a project in Test Studio, click the **Connect** button in the **Source Control** ribbon. Select **Git**, choose **Local** and fill in the appropriate information click **Connect** and **OK**.

   ![Connect to Git](https://www.telerik.com/teststudio/documentation/assets/45b532277c815fecb5c275c7ff8eefaa/fig1_localrepo.png)

2. For local repository only **Commit** is available as an option.

   ![Available Options](https://www.telerik.com/teststudio/documentation/assets/e291ddaa152c3148399d708ad4c2053a/fig2_availableoptions.png)

3. The **Manage Branches** dialog could be accessed from the Project Explorer options menu or from the Source Control ribbon.

   ![Manage Branches](https://www.telerik.com/teststudio/documentation/assets/e67778731d20a0b606cd059c5d2c2c36/fig3_managebranches.png)

4. The **Manage Branches** dialog contains a list of local branches. The initially created branch is set as default one and is called master.

   ![Default Branch](https://www.telerik.com/teststudio/documentation/assets/d04e92b0f1cbe1e4c1347aca0f965420/fig4_defaultbranch.png)

5. In the **Manage Branches** dialog a new local branch could be created. Enabling the checkbox "Checkout after creation" will automatically checkout the newly created branch.

   ![Create Branch](https://www.telerik.com/teststudio/documentation/assets/77d437c549a49e436a7a7e21ed107301/fig5_createbranch.png)

6. The newly created branch will appear in the list and will be marked as checked out with a red arrow sign in front of its name. Once the dialog is closed the project will be reloaded to display the new branch.

   ![New Branch](https://www.telerik.com/teststudio/documentation/assets/843e9a97a256402aed33cd91722c43d2/fig6_newbranch.png)

7. The current branch name is displayed in the Source control ribbon. It also could be double checked in the **Manage Branches** dialog at any time.

   ![Current Branch](https://www.telerik.com/teststudio/documentation/assets/af78b3ac544f84db5cf8a4b88ffb0e76/fig7_currentbranch.png)
