使用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