用個 Project 來還原發生情況,開個 WinForm Project 並新增 Form2,Form2 為正在撰寫的需求
VS 檔案總管檔案狀態
利用 git 來看檔案狀態
接到插單需求,要把原本需求的 Form2 暫存起來,下 git stash -u 把 untrack 檔案也一併暫存起來
新增 Form3 模擬差單需求已完成,並進行 commit 啦
使用 git stash pop 回復暫存,在 project 上發生衝突啦
回到 VS 內就跳出這個 Error
VS 方案總管內可以看見 StashMerge 載入失敗,原來卸載情況下,可以編輯 Project 檔案
打開 Project 後,就可以發現發生衝突的地方,理解是新增 Form2 和 Form3 在 Project 內都是在同一個位置,所以 Form3 完成後,把暫存的 Form2 抓回來,就衝突啦
修正衝突,Form2 和 Form3 都要存在 project 內
重新載入 Project
project 內有衝突解決,所以在 VS 方案總管內,會有個小綠色分支圖示顯示
解決衝突後,當然是要進行 Commit 囉,把衝突解決 commit 起來,網路教學都這樣教的
把衝突解決 commit 後,就發現 Form2 還是在 untrack 狀態,但是 project 內的 Form2 設定,已經被 commit 了
VS 方案總管內 project 已經是鎖頭圖示,Form2 還是加號圖示
git status 內沒有 project 有修改紀錄
進行到這邊,Form2 暫存回來後,已經亂掉啦,這時候再下 git stash 暫存的話,會變成 Form2 暫存,Project 內的設定偵測不到 Form2,也是 GG
查了一下網路資料,有個解法是把 MergeConflict commit 刪除,就會恢復正常
下 git reset 或 在 VS 內操作
reset 後,在VS 方案總管內,就可以看見 Form2 的狀態恢復正常
從 [Team Explorer - 變更] 來觀察
利用 git 語法來觀察
git diff 來觀察 project 檔案
解決 merge conflict 後再刪除 merge conflict commit 雖然可以回復到正常狀態,感覺就很奇怪 >.<,還是養成開 branch 撰寫需求,遇到插單時暫存 stash 後,再切到其他 branch 去撰寫的習慣,通通在同一個 branch 上撰寫,似乎不是一個好習慣
- 延伸閱讀
- [VSTS] Stash 暫存
![[VSTS] git stash 衝突-20](https://c1.staticflickr.com/5/4163/34709693636_40855611b5.jpg)
![[VSTS] git stash 衝突-2](https://c1.staticflickr.com/5/4169/34364567580_fb077b9b88.jpg)
![[VSTS] git stash 衝突-1](https://c1.staticflickr.com/5/4274/33940228583_10b1372126_z.jpg)
![[VSTS] git stash 衝突-3](https://c1.staticflickr.com/5/4248/34364567530_03d81ff80d_z.jpg)
![[VSTS] git stash 衝突-4](https://c1.staticflickr.com/5/4226/33940228273_fa4f928675.jpg)
![[VSTS] git stash 衝突-5](https://c1.staticflickr.com/5/4227/33940228183_82d6795714_z.jpg)
![[VSTS] git stash 衝突-6](https://c1.staticflickr.com/5/4222/34587119222_90cb2e53ce.jpg)
![[VSTS] git stash 衝突-7](https://c1.staticflickr.com/5/4222/34587119152_05673ab162.jpg)
![[VSTS] git stash 衝突-8](https://c1.staticflickr.com/5/4188/33940229433_ef89233735_z.jpg)
![[VSTS] git stash 衝突-9](https://c1.staticflickr.com/5/4221/34587120182_d7e1abab11_z.jpg)
![[VSTS] git stash 衝突-10](https://c1.staticflickr.com/5/4158/34587120082_ff472e8a2a.jpg)
![[VSTS] git stash 衝突-11](https://c1.staticflickr.com/5/4187/34587120002_0ff1565ce7.jpg)
![[VSTS] git stash 衝突-12](https://c1.staticflickr.com/5/4177/34587119962_3c98e307b6.jpg)
![[VSTS] git stash 衝突-14](https://c1.staticflickr.com/5/4272/33940228963_5a86f17fbc.jpg)
![[VSTS] git stash 衝突-13](https://c1.staticflickr.com/5/4245/33940229123_f2b8fce549_z.jpg)
![[VSTS] git stash 衝突-15](https://c1.staticflickr.com/5/4223/33940228913_7e7de32d65_z.jpg)
![[VSTS] git stash 衝突-19](https://c1.staticflickr.com/5/4220/34365014060_62b76c23de.jpg)
![[VSTS] git stash 衝突-17](https://c1.staticflickr.com/5/4271/34587119742_76d98c28b2.jpg)
![[VSTS] git stash 衝突-18](https://c1.staticflickr.com/5/4176/33940228673_53d840f6d6_z.jpg)
![[VSTS] git stash 衝突-16](https://c1.staticflickr.com/5/4176/34587119832_53534bb65a_z.jpg)
沒有留言:
張貼留言