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。

posted on   乐之者v  阅读(10044)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示