Git – Create New Branch From Existing Branch


To create a new branch from existing one you first have to checkout new branch locally, then push it to remote so other can see it. Below are the exact commands.

  1. Create new branch based on existing one. New branch will be only local for now.

    git checkout -b {NEW_branch_name} {SOURCE_branch_name}

  2. Push changes to origin; in other words: push newly created branch to remote for everyone else.

    git push origin {NEW_branch_name}

  1. tyler says

    -thanks for this! -was concisely helpful!

  2. Jcarnelian says

    This doesnt work it gives me
    ! [rejected] -> (non-fast-forward)

    1. Sebastian Expert says

      that means that remote branch has changes which you dont have locally.
      You need to do ‘git pull origin YOUR_BRANCH_NAME’

Leave A Reply

Your email address will not be published.