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

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

    • git branch: Shows all your branches
    • git branch newbranch: Creates a new branch
    • git checkout -b newbranch: Creates a new branch and switches to that branch immediately. This is the same as git branch newbranch followed by git checkout newbranch.

提交回复
热议问题