I am a new user of Git. I have forked a repository called Spoon-Knife (available for practicing forking with Git). Then, I cloned it locally by running
git c
The modern Git should able to detect remote branches and create a local one on checkout.
However if you did a shallow clone (e.g. with --depth 1
), try the following commands to correct it:
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git fetch --all
and try to checkout out the branch again.
Alternatively try to unshallow your clone, e.g. git fetch --unshallow
and try again.
See also: How to fetch all remote branches?
This error can also appear if your git branch is not correct even though case sensitive wise. In my case I was getting this error as actual branch name was "CORE-something" but I was taking pull like "core-something".
git fetch && git checkout branch-name
Solution:
To fix it you need to fetch first
$ git fetch origin
$ git rebase origin/master
Current branch master is up to date.
$ git checkout develop
Branch develop set up to track remote branch develop from origin.
Switched to a new branch ‘develop’
Try cloning before doing the checkout.
do git clone "whee to find it" then after cloning check out the branch
My friend, you need to create those corresponding branches locally first, in order to check-out to those other two branches, using this line of code
git branch test-branch
and
git branch change-the-title
then only you will be able to do git checkout to those branches
Also after creating each branch, take latest changes of those particular branches by using git pull origin branch_name as shown in below code
git branch test-branch
git checkout test-branch
git pull origin test-branch
and for other branch named change-the-title run following code =>
git branch change-the-title
git checkout change-the-title
git pull origin change-the-title
Happy programming :)