Git报错:failed to push some refs to xxxxx
![> [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TPFlD75K-1681395928888)(C:\Users\小卢\AppData\Roaming\Typora\typora-user-images\image-20230412234249067.png)]](https://img-blog.csdnimg.cn/420ae9f1a5b64bbf88bc869309423bcd.png)
To https://xxxxxxxxxxxx.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://xxxxxxxx.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 did not exit cleanly (exit code 1)
解决方法1:(此方法将导致仓库数据统计中的贡献者只有最后一个上传者)
若远程分支上那些提交都不需要了
直接输入git push origin master -f,强行让本地分支覆盖远程分支。:
解决方法2:
2.1.Git Bash here:(如果鼠标右键有Git Bash here的话可以跳过这个部分)
右键显示Git Bash here
window+r

找到shel的位置


左边新建一个项,右边新建一个字符串值
左边的项,修改为Git Bash Here,右边修改为Icon



找到你之前下的git的文章地址,找到git bash.exe文件地址,将这个地址放到Git Bash Here中去


在Git Bash Here下建一个项
项的名称改为command

点击默认
将其中的值改为地址 +空格+“–cd=%v.”

然后就好啦

2.2.git clone 地址

如果出现下面这种情况git init一下
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dD3W2AEp-1681395928894)(C:\Users\小卢\AppData\Roaming\Typora\typora-user-images\image-20230413191622253.png)]
2.3三个命令
三个命令
- **git add ***
- git conmit -m ‘“hello”
- git push origin master
然后就可以了













![【洛谷 P1003】[NOIP2011 提高组] 铺地毯 题解(数组+贪心算法)](https://img-blog.csdnimg.cn/img_convert/823ec298bd31c29535b292affc8edf1f.png)






