What is the difference between “git branch” and “git checkout -b”?

后端 未结 7 1727
礼貌的吻别
礼貌的吻别 2020-11-29 16:18

I used git checkout -b to create a new branch. I think that git branch does the same thing. How do these two commands differ, if they differ at all

7条回答
  •  误落风尘
    2020-11-29 16:27

    Essentially :

    A-git branch lets you create a branch plain and simple.

    B -git checkout -b allows you to create a branch and switch to it at the same time.

    When will you use which ? 1- git branch when you want to create a branch but stay on the current branch. 2- git checkout -b when you want to create and switch. If you look at it is intuitive to create a branch and switch to it. So the choice is yours :)

提交回复
热议问题