I'd like to create local branch based on other branch. For example I type:
git checkout -b feature1 release1.1.3
After that I get:
fatal: git checkout: updating paths is incompatible with switching branches.
What is the problem with this ?
I'd like to create local branch based on other branch. For example I type:
git checkout -b feature1 release1.1.3
After that I get:
fatal: git checkout: updating paths is incompatible with switching branches.
What is the problem with this ?
git branch <new-branch-name> <existing-branch-name>
To create a branch based on another branch, the simplest way is to first checkout the base branch, then create a new branch from there. If I understand your question right, that's exactly what you want to do.
Now, seeing as you are using the -b
flag in your branching, you may have working changes that you want to keep. If that's the case, you should push them onto the stash, check out the base branch, create the new branch, and pop the stash.
Do git pull
first to make sure all you local branches are up-to-date. And then you can cut the branch.
The syntax is
$ git checkout -b <branch> --track <remote>/<branch>
or
$ git checkout <remote>/<branch> -b <branch>
You meant git branch feature1 release1.1.3
assuming you want a branch called feature1 to be based upon the release1.1.3 commit. What you called there should also work but you also have an actual folder called 'release1.1.3' in your working tree and git is getting confused about whether you mean the branch/tag or the folder.
You could try just giving the actual commit id of release1.1.3.
Use
git checkout -b <new-branch> <existing-branch>
By default git checkout -b
will base the new-branch
off the current HEAD. An optional additional branch parameter can be passed to git checkout
. In the above example, <existing-branch>
is passed which then bases new-branch
off of existing-branch instead of the current HEAD.
Reference: https://www.atlassian.com/git/tutorials/using-branches/git-checkout