1

I have a repository with many brunches and I cloned it.

git clone myproject
cd myproject

Now I wish to switch to branch, other than master.

How should I do this?

git checkout -b mybranch

doesn't work, it creates new branch with given name instead.

Dims
  • 47,675
  • 117
  • 331
  • 600
  • 2
    `git checkout mybranch` – Ry- Apr 04 '18 at 22:08
  • This is one of the fundamental git commands. Surely you could have found the answer you needed by a quick search? – evolutionxbox Apr 04 '18 at 23:28
  • Git is supposed to make life easier .. But instead it forces us to learn the tool and makes life complicated. Why the hell on the earth I should checkout the whole repository rather than just checking out a specific branch.. – Stunner Nov 04 '20 at 04:32
  • And GIT came up with multiple version of commands with same functionality to cover up the design mistakes and its naming conventions are too messy and ambiguous. Lot of people simply do "rm -rf" and checkout fresh copy if something is messed up in GIT. – Stunner Nov 04 '20 at 04:34
  • https://qph.fs.quoracdn.net/main-qimg-d28f46654cd788d9c8e29a04bf1bf2f2.webp This sums up the whole GIT – Stunner Nov 04 '20 at 04:35

0 Answers0