Skip to content

4. Checkout a branch using GitBash

NatashaChetwynd edited this page Nov 26, 2019 · 5 revisions

Checkout a branch using command line

Once the repository has been cloned to your local machine, complete the following steps to navigate the branches.

  1. Open GitBash and change your directory to where you have cloned the repository to on your local machine. If you are unsure how to do this then follow instruction 2 here. You should navigate to the codonPython folder.

  2. Then type the following into GitBash to list all available branches

git branch -a

All of the currently available branches will be listed. You can then use the branch names as a reference to navigate and checkout the desired branch. The branch with a * next to it is the branch you are currently on. It is good practice to never make changes directly to the master branch.

Example of branches

  1. Checkout the branch that you want to use by typing the following into GitBash.

git checkout <feature_branch>

Checkout

  1. You can also create a new branch if required using the code below. We suggest that similar pieces of work should be completed on the same branch. Branch names should be simple and indicative of the work being done on that branch - see previous branch names for examples.

git checkout -b <new_branch_name>

  1. Use the following code to confirm you are working on the correct branch.

git branch

The branch you have just checked out should now be highlighted with a *.

current-branch