Git Checkout Another Branch
I Run: Git Checkout Mygithub/Master but for Some Reason, Running 'Git Status' Shows "Not Currently on Any Branch". Running: Git Checkout Master and Then Git...
I run:
git checkout mygithub/master
but for some reason, running 'git status' shows "not currently on any branch". Running:
git checkout master
and then git status, says that I'm now on branch master. Now I want to switch to another branch. Running git checkout anotherbranch works, but git status says I am still on branch 'master'. What am I doing wrong?
3 Answers
mygithub/master is a remote branch. To create a local branch based off of that remote branch, you have to use git checkout -b mymaster mygithub/master. Git tries to make this easy for you: if you write git checkout branchname, and branchname only exists in a remote, but not locally, Git will automatically set up a local branch with <remote>/branchname being its parent.
If you want to switch to another branch then run this command:
git checkout branch name
If you want to delete a branch then run this command:
git branch -D branch name
If you want to create a new branch then run this command:
git checkout -b branch
If you want to checkout from master branch just run this command in your terminal
git checkout -b BRANCH_NAME