如何解決git checkout "Please commit your changes or stash them before you switch branches" ?
當切換git branch時出現error "Please commit your changes or stash them before you switch branches",最直覺的做法是依指示先把code commit 或stash起來。不過小弟曾遇到一個情況,code已commit了,也做了stash command,但checkout 時仍然出現同樣error。
最後我沒有追查原因了,檢查沒有未commit的檔案後,直接加上 --force
去強行把當前的file覆蓋一次。
git checkout master -f
或
git checkout master --force