Git報錯的解決方案匯總


錯誤1:

error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.

解決方案:

https://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me

 

錯誤2:

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
no changes added to commit (use "git add" and/or "git commit -a")

解決方案:

https://stackoverflow.com/questions/7704480/why-does-git-commit-not-save-my-changes

先執行git add 操作,然后才能執行git commit操作

 

錯誤3: 
error: failed to push some refs to
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解決方案:https://stackoverflow.com/questions/10298291/cannot-push-to-github-keeps-saying-need-merge

 

錯誤4:

Local changes were not restored
Before update your uncommitted changes were saved to stash.
Update is not complete, you have unresolved merges in your working tree
Resolve conflicts, complete update and restore changes manually.

解決方案:https://www.jianshu.com/p/bc06970cb605

 

錯誤5:

error: The following untracked working tree files would be overwritten by merge:
        .idea/junitgenerator-prj-settings.xml
Please move or remove them before you can merge.
Aborting

解決方案:

將提示中的文件,如上提示的是.idea/junitgenerator-prj-settings.xml,將這個文件刪除。

然后再執行下面的操作:

git pull origin master
git add .
git commit -m "本次提交的名稱"
git push origin master

 

錯誤6:

$ git push origin master

error: failed to push some refs to 'https://github.com/.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解決方法:想將本地倉庫代碼提交到遠程倉庫,必須獲取和合並最新的遠程倉庫代碼。先執行git pull操作,保持代碼版本一致,然后再git push。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM