使用git 过程中常见报错

使用git 的各种报错

在git 上创建了一个仓库(附带README文件),在上传本地文件的过程中出现的问题
1:git remote add 自定义远程仓库名字 (本次我的是my_summary)远程仓库的地址
2:git add .
3:git commit “注释”
4:git push -u 远程仓库名字 本地分支名字

报错:fatal: not a git repository (or any of the parent directories): .git

此处报错是因为少了初始化:git init

  • 之后再执行以上命令到git push
报错:
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/fairy66/My_summary.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.

此处的报错大概意思是“远程仓库中的一些东西,本地是没有的,所以提交被拒绝”,需要执行git pull

  • 接着执行git pull
报错:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
   git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
   git branch --set-upstream-to=my_summary/<branch> master

大概意思是你当前分支没有指定跟踪信息,需要指定与哪个分支合并。根据最后一行提示进行操作
解决:

git pull 远程仓库名字  本地分支名字

再执行

git branch --set-upstream-to=my_summary/<branch> master   
<branch> 指的是远程分支的名字  

**远程分支的信息也可以使用git branch -a或者git branch -r 来查询,此处如下:
在这里插入图片描述
执行完这个命令,会提示关联成功,
在这里插入图片描述

  • 再次执行git pull
报错:fatal: refusing to merge unrelated histories

解决-执行以下命令:翻译过来就是循允许不相关的历史记录

git merge my_summary/master --allow-unrelated-histories

之后出现:
在这里插入图片描述
输入i:注释——ESC——:wq回车—— git push -u 远程仓库名字 本地分支名字

如下报错

fatal: unable to access 'https://github.com/fairy66/gitTest.git/': OpenSSL SSL_read: Connection was reset, errno 10054

解决 git config --global http.sslVerify "false"
如下报错

fatal: unable to access 'https://github.com/fairy66/gitTest.git/': Failed to connect to github.com port 443: Timed out

解决 .git/config中的https://地址改成SSH地址

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值