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.
-
Create new branch based on existing one. New branch will be only local for now.
git checkout -b {NEW_branch_name} {SOURCE_branch_name}
Specifying
-b
parameter causes a new branch to be created. More about it here -
Push changes to origin; in other words: push newly created branch to remote for everyone else.
git push origin {NEW_branch_name}
! [rejected] -> (non-fast-forward)
If you get this error make sure that your local branch is up to date with remote branch. Simply do git pull origin YOUR_BRANCH_NAMEM
more on GitHub help page.
Other cause on Windows, might be that the local shared repository has a write lock from other process running in the system. In this case try to shutdown for example VMWare Workstation or Visual Studio and try again..
If this does't work, you can try to ask community at Stackoverflow in this question.
Thanks very much. very helpful!
Thanks very much for this
-thanks for this! -was concisely helpful!
This doesnt work it gives me
! [rejected] -> (non-fast-forward)
that means that remote branch has changes which you dont have locally.
You need to do ‘git pull origin YOUR_BRANCH_NAME’