1. 程式人生 > >git pull遇到錯誤:error: Your local changes to the following files would be overwritten by merge:

git pull遇到錯誤:error: Your local changes to the following files would be overwritten by merge:

覆蓋 eset class 代碼更新 hang err ast div clas

  今天用git pull將服務器的代碼拉到本地時,遇到錯誤,Your local changes to the following files would be overwritten by merge:,則可用以下方法解決:

  方法1:如果你想保留剛才本地修改的代碼,並把git服務器上的代碼pull到本地(本地剛才修改的代碼將會被暫時封存起來)

git stash
git pull origin master
git stash pop

如此一來,服務器上的代碼更新到了本地,而且你本地修改的代碼也沒有被覆蓋,之後使用add,commit,push 命令即可更新本地代碼到服務器了。

方法2、如果你想完全地覆蓋本地的代碼,只保留服務器端代碼,則直接回退到上一個版本,再進行pull:

git reset --hard
git pull origin master 

註:其中origin master表示git的主分支。

git pull遇到錯誤:error: Your local changes to the following files would be overwritten by merge: