Branches

    Source: 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 -a
    

    Remote only πŸ”—

    git branch -r
    

    Local only πŸ”—

    git branch
    

    Checkout 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 develop
    

    Create 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_branch
    

    Delete 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