git 报错的解决办法--强制上传文件

 更新单个文件的命令

 git checkout origin/main -- file.txt

1. 在idea中重新push自己的项目
强制上传

git push -u origin master -f

2.删除本地后,强制更新:

git fetch --all     ;获取所有的;  

1. 更新有问题,提示 某些无法更新,就关掉当前的pycharm 工具

2. 提示 解决git提交代码时报错: Unable to create ‘XXX/.git/index.lock‘: File exists   ----删除   index.lock 文件


git reset --hard origin/master     ;l然后重置为服务器端的最近版本
git pull   更新最新的

 

一、Git操作和报错问题解决

1 .创建本地仓库

2. 上传步骤和下载步骤

二、报错解决方案

1.Push rejected (Push was rejected, and update failed with error.)

2.error: src refspec zhangshaohe does not match any

3.! [rejected] master -> master (fetch first)

4.fatal: repository ‘https://xxx@bitbucket.org/xxx.git/’ not found

5.Cant’t Update (No tracked branch configured for branch master or the branch doesn’t exist.)

一、Git操作和报错问题解决
1 .创建本地仓库
git config --global user.name "shaohe-zhang" #配置注册时的用户名
git config --global user.email "805414400@qq.com" #配置注册时的邮箱
git config --list #检查配置信息
mkdir j2ee
cd j2ee
git init #初始化
在本地仓库中,创建文件1.txt
git add 1.txt #新增文件到git中处理
git commit -m "提示信息" #提交,设置说明信息
git remote add origin https://gitee.com/nutony/j2ee.git #远程仓库
git push -u origin mas`在这里插入代码片`ter #把本地仓库的资源 提交给Git服务器
2. 上传步骤和下载步骤
上传
git add .#.代表上传本文件夹下所有文件
git commit -m "提示消息"
git push origin master

下载
git clone https://gitee.com/cgblpx/cgb210801.git #clone后边是git仓库地址

二、报错解决方案
1.Push rejected (Push was rejected, and update failed with error.)
报错代码如下(示例):

Push rejected
Push was rejected, and update failed with error.
解决方法:

切换到自己项目所在的目录,右键选择GIT BASH Here,Idea使用Alt+F12在窗口中输入命令

git pull
git pull origin master
git pull origin master --allow-unrelated-histories

在idea中重新push自己的项目
如何还是不行进行强制上传

git push -u origin master -f
2.error: src refspec zhangshaohe does not match any
报错代码如下(示例):

error: src refspec zhangshaohe does not match any
error: failed to push some refs to 'https://gitee.com/Ys1550115/the-happy-room.git'
解决方法:

错误原因是,我本地分支是master,我要提交到done分支,因为这是不同的分支,所以要以这种形式提交(mester:done)

git push origin master:done
3.! [rejected] master -> master (fetch first)
报错代码如下(示例):

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/zhang-shaohe/workspace.git'
解决方法:

方法一 可以通过如下命令进行代码合并

git pull --rebase origin master
#合并完之后重启dom窗口,重新运行如下命令进行提交
git push origin master
方法二 通过命令强制提交

git push -u origin master -f
4.fatal: repository ‘https://xxx@bitbucket.org/xxx.git/’ not found
报错代码如下(示例):

fatal: repository 'https://xxx@bitbucket.org/xxx.git/' not found
解决方法:

输入下面这行命令设置远程url为修改后的地址

git remote set-url origin https://xxx@xxx/xxx/new_directory.git

改了之后可以查看remote链接,命令如下

git remote -v
5.Cant’t Update (No tracked branch configured for branch master or the branch doesn’t exist.)
报错代码如下(示例):

No tracked branch configured for branch master or the branch doesn't exist.
解决方法:

#在idea的终端里运行如下命令即可
git branch --set-upstream-to origin
#如果不行尝试如下命令
git branch --set-upstream-to origin/maste
发现这个错误的时候可以用git remote -v命令确认一下链接是否正确

不正确就执行替换remote的命令
————————————————
原文链接:https://blog.csdn.net/whx02046/article/details/125265596

posted @   hello_tree  阅读(608)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示