Switch/Checkout (to existed branch)

簡單說: Working tree Switch/Checkout 到某 branch

Switch/Checkout : HEAD attach some branch
如果 commit 上沒有 branch , HEAD 就會變成 Detached
(個人喜歡在 Log 畫面做 Switch/Checkout , 但這裡先說明在資料夾如何切換已存在的分支)


二種方法:

 1. TortoiseGit
 2. msysGit


1. TortoiseGit

Wanted: master Switch/Checkout to Release




Method:

TortoiseGit -> Switch/Checkout



Select "Release" Branch



Push OK



Success Message:

Push Close


Result:





2. msysGit

Select Branch name directly




maybe wait a while

confirm





================================================================

看起來 msysGit 提供的 Switch/Checkout 比較方便

但是如果 Working tree 仍有修改 , 是無法完成 Switch/Checkout 動作的
(If working tree is modified, Switch/Checkout will fail.)

此時, TortoiseGit 會給出 Error (如下圖), 而 msysGit 則不會
(TortoiseGit will show the error, but msysGit will not.)




solution 1: commit first
solution 2: stash
solution 3: revert local changes






沒有留言:

張貼留言