git pull覆蓋掉本地專案腫麼找回?

2021-10-10 00:18:40 字數 759 閱讀 4554

新建的倉庫在上傳本地專案時,需要先拉取git端建立的readme.md等本地不存在的檔案,git pull之後本地的檔案卻被覆蓋掉,那麼怎麼辦呢?

git reflog可以檢視該git專案的操作日誌,結果如下:

$ git reflog

3405d7a (head, origin/master) head@: reset: moving to 3405d7a

a508484 (master) head@: reset: moving to a508484

3405d7a (head, origin/master) head@: pull --rebase origin master: checkout 3405d7a7664c7975b565a6cdb0e26268333a0ecd

a508484 (master) head@: commit (initial): first commit

git reset --hard head@head為版本號,就前面那一串數字,n是你要回退到的引用位置)

$ git reset --hard a508484

updating files: 100% (56/56), done.

head is now at a508484 first commit

ok!呼!done!

ref

git pull和本地檔案衝突

同事在使用git pull 時,經常會碰到有衝突的情況,提示如下資訊 error your local changes to c environ.c would be overwritten by merge.aborting.please,commit your changes or stash ...

git pull和本地檔案衝突

使用git pull 時,經常會碰到有衝突的情況,提示如下資訊 error your local changes to c environ.c would be overwritten by merge.aborting.please,commit your changes or stash the...

git pull 和本地檔案衝突

在使用git pull 時,經常會碰到有衝突的情況,提示如下資訊 error your local changes to c environ.c would be overwritten by merge.aborting.please,commit your changes or stash th...