git 強制覆蓋本地代碼

一 問題

  公司的ssh配置出問題了,只能走HTTPS,ssh的pull 跟push 都提示失敗

$ git pull
ssh: connect to host ***.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

找走idea關聯HTTPS方式能提交 的同學,幫忙把代碼提交,繼續打包提測。


二 ssh 恢復後

git pull
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 16 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (16/16), done.
From XXXXXXX.com:AAAAAAAAAAAAAAA/BBBBBBBBB/CCCCCCCC
   743f3f4..e505a37  dev/CCCCCCCCC-0-16 -> origin/dev/CCCCCCCCCCCCC-0-16
Auto-merging XXXXXXXXXXX.java
CONFLICT (content): Merge conflict in XXXXXXXXXXXXXXXXX.java
.....

不想再去逐條解決衝突了,因爲都是我之前修改的。所以直接覆蓋就好。

1. git fetch --all

Fetching origin
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
From XXXx.com:s.....

2. git reset --hard origin/master

或者指向具體的分支

git reset --hard origin/<branchname>

HEAD is now at e505a37 更新賬單

3. git pull

好了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章