Branches
Chester Wyke October 28, 2023 Updated: April 26, 2025 #GitSource: https://www.nobledesktop.com/learn/git/git-branches
See branches
NB: The current branch will have a * next to it.
Both local and remote
git branch -aRemote only
git branch -rLocal only
git branchCheckout a branch
Use git switch or git checkout followed by the branch name.
Prefer switch as checkout has other functionality that it can do to restore files as per SO and switch was introduced to be used for changing branches.
Note do not include the remote/origin in the command it will automatically create the local branch and set it up to track the remote branch.
Eg to check out develop use:
git switch developCreate a branch
Source: https://www.atlassian.com/git/tutorials/using-branches/git-checkout
Create Only
git branch new_branch
Create and checkout
git checkout -b new_branchDelete a remote tracking branch after the branch has been deleted on the remote
- r is for remote
- d is for delete
git branch -rd origin/TRACKING_BRANCH_NAME