How can I switch to another branch in git?

后端 未结 9 660
难免孤独
难免孤独 2021-01-29 17:38

Which one of these lines is correct?

git checkout \'another_branch\'

Or

git checkout origin \'another_branch\'
         


        
9条回答
  •  梦毁少年i
    2021-01-29 18:28

    [git checkout "branch_name"]

    is another way to say:

    [git checkout -b branch_name origin/branch_name]

    in case "branch_name" exists only remotely.

    [git checkout -b branch_name origin/branch_name] is useful in case you have multiple remotes.

    Regarding [git checkout origin 'another_branch'] I'm not sure this is possible, AFAK you can do this using "fetch" command -- [git fetch origin 'another_branch']

提交回复
热议问题