NoBugs
NoBugs

Reputation: 9496

Git checkout second remote 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 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?

Upvotes: 32

Views: 162891

Answers (3)

S.m.g. baquer
S.m.g. baquer

Reputation: 429

If you want to checkout from master branch just run this command in your terminal

git checkout -b BRANCH_NAME

Upvotes: -7

Viru
Viru

Reputation: 163

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

Upvotes: 15

knittl
knittl

Reputation: 265131

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.

Upvotes: 42

Related Questions