Git checkout remote branch到local branch的方法如下。
在checkout到一條remote branch時,應該用git checkout -t <remote_branch>指令,如此便會自動建立一個與遠端同名的local branch,並以此local branch追蹤remote branch。
例如checkout遠端分支origin/dev的命令如下:
$ git checkout -t origin/dev
這樣checkout remote branch時就會自動建立一個local branch dev,並追蹤遠端分支origin/dev。
如果直接使用git checkout <remote_branch>而沒加上-t參數,則會出現Git HEAD detached的情況。
沒有留言:
張貼留言