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

后端 未结 7 1733
礼貌的吻别
礼貌的吻别 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:37

    git branch creates the branch but you remain in the current branch that you have checked out.

    git checkout -b creates a branch and checks it out.

    It could be considered a short form of:

    git branch name
    git checkout name
    

提交回复
热议问题