git 常見錯誤及處理

同步遠程倉庫到本地

git pull=git fetch + merge

$ git pull --rebase origin master

error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

 

有修改了的文件,但是沒有提交。這種情況可以用git status查看哪些文件修改了沒有提交,可以提交這些文件。或者,放棄這些文件的修改(git restore)



git status

git restore DoctoralDissertationCollection/settings.py



error: The following untracked working tree files would be overwritten by merge:
        user/__init__.py
Please move or remove them before you merge.

Aborting
error: could not detach HEAD

 

有文件沒有加入版本控制中,但是下載的新文件和該文件同名,此時,可以刪除本地的該文件。



Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .idea/workspace.xml
        modified:   DoctoralDissertationCollection/settings.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        DoctoralDissertationCollection/__pycache__/__init__.cpython-38.pyc
        DoctoralDissertationCollection/__pycache__/settings.cpython-38.pyc



 

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