Branches

Creating a Branch

  • git branch <branch-name>

    -creates a new branch with the name "<branch-name>"

Listing Branches

  • git branch

    -lists all the local branches.

  • git branch -r

    -lists all the remote branches.

  • git branch -a

    -lists all branches.

Changing branches

  • git checkout <branch-name>

    -Switch to the existing branch "<branch-name>" and update the working directory.

  • git checkout -b <branch-name>

    -Create a new branch "<branch-name>" with current branch as parent branch and switch to the <branch-name>

Deleting Branches

  • git branch -d <branch-name>

    -delete a branch that is merged.

  • git branch -D <branch-name>

    -delete a branch, whether merged or not.

Last updated