How can I switch to another branch in git?

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

Which one of these lines is correct?

git checkout \'another_branch\'

Or

git checkout origin \'another_branch\'
         


        
9条回答
  •  悲&欢浪女
    2021-01-29 18:26

    Switching to another branch in git. Straightforward answer,

    git-checkout - Switch branches or restore working tree files

    git fetch origin         <----this will fetch the branch
    git checkout branch_name <--- Switching the branch
    

    Before switching the branch make sure you don't have any modified files, in that case, you can commit the changes or you can stash it.

提交回复
热议问题