git: switch branch without detaching head

后端 未结 4 1660
野趣味
野趣味 2020-11-28 18:38

I have a repository on github with a main branch (master) and a branch for some experimental work. I made some commits and pushed to the experimental branch and everything

4条回答
  •  情深已故
    2020-11-28 19:21

    With Git 2.23 (August 2019), you would use the git switch command

    If you have a remote branch of the same name, it will be automatically tracked:

    $ git switch new-topic
    Branch 'new-topic' set up to track remote branch 'new-topic' from 'origin'
    Switched to a new branch 'new-topic'
    

提交回复
热议问题