前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Github自身踩到的坑

Github自身踩到的坑

作者头像
双愚
发布2018-05-28 15:02:08
1.9K0
发布2018-05-28 15:02:08
举报
文章被收录于专栏:重庆的技术分享区
image.png
image.png

用Github有一两年了,是时候总结一下以前踩得坑了,这些坑开始时还真把自己摔得不轻!!!!! 小插曲:自己以前用hexo搭建的博客,每次写博客都要新建.md文件等初始化步骤,然后提交,有些繁琐,再加上自己又换了台电脑,又要部署hexo(虽然不需要重新部署),但还是有些步骤,索性用简书写,方便快捷些!

git pull时ssh: Could not resolve hostname github.com: Name or service not known, fatal: Could not read from remote repository.

123456

$ git pullssh: Could not resolve hostname github.com: Name or service not knownfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.

这个错误好醉,是因为没网了,就很皮

git本地仓库首次push到远程仓库出现错误 ! [rejected] master -> master (fetch first)

新建好本地的仓库和远程仓库之后,

经过 git add . 然后 git commit -m "......" 最后想推送到远程仓库的时候

git push -u origin master 出现下图错误

image.png
image.png

解决很简单,使用强制推送 使用下面的命令 git push -f origin master

附上git push 的说明

12345678910111213141516171819

NAMEgit-push - Update remote refs along with associated objectsSYNOPSISgit push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [--prune] [-v | --verbose] [-u | --set-upstream] [--[no-]signed|--sign=(true|false|if-asked)] [--force-with-lease[=<refname>[:<expect>]]] [--no-verify] [<repository> [<refspec>…​]]-f --forceUsually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. Also, when --force-with-lease option is used, the command refuses to update a remote ref whose current value does not match what is expected.This flag disables these checks, and can cause the remote repository to lose commits; use it with care.Note that --force applies to all the refs that are pushed, hence using it with push.default set to matching or with multiple push destinations configured with remote.*.push may overwrite refs other than the current branch (including local refs that are strictly behind their remote counterpart). To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the<refspec>... section above for details.

github上传时出现error: src refspec master does not match any

如下:

image.png
image.png

引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

解决方法:先提交文件git add . git commit -m "" 例如下:

1234

touch READMEgit add README git commit -m 'first commit'git push origin master

fatal: unable to create ‘../../.git/index.lock’:File exists

mark
mark

解决方法:把文件index.lock删掉

###Permission denied (publickey). fatal: The remote end hung up unexpectedly

错误原因:github上没有配置公钥 解决方法:配置公钥,并放到github上 GitHub设置公钥在windows下面

  1. 安装git,从程序目录打开 “Git Bash”
  2. 键入命令:ssh-keygen -t rsa -C “email@email.com” “email@email.com”是github账号
  3. 提醒你输入key的名称,输入如id_rsa 如果执行成功。返回

Generating public/private rsa key pair. Enter file in which to save the key (/home/forwhat.cn/.ssh/id_rsa): 在这里就是设置存储地址了.反正我是直接按的回车,一直回车

  1. 在C:\Documents and Settings\Administrator\下产生两个文件:id_rsa和id_rsa.pub
  2. 把4中生成的密钥文件复制到C:\Documents and Settings\Administrator.ssh\ 目 录下。
  3. 用记事本打开id_rsa.pub文件,复制内容,在github.com的网站上到ssh密钥管理页面,添加新公钥,随便取个名字例如你的电脑名

需要注意步骤2中产生的密钥文件在当前用户的根目录,必须把这两个文件放到当前用户目录的“.ssh”目录下才能生效。

————2017/8/14

There is no tracking information for the current branch. Please specify which branch you want to merge with.

mark
mark

是因为本地分支和远程分支没有建立联系 (使用git branch -vv 可以查看本地分支和远程分支的关联关系) .根据命令行提示只需要执行以下命令即可

  • 如果不想新建分支 git branch --set-upstream master origin/master
  • 如果想新建分支 git branch --set-upstream-to=origin/远程分支的名字 本地分支的名字

git branch –set-upstream-to=origin/develop developgit branch --set-upstream develop origin/develop (develop为新建分支name) 同时推荐大家看一下下面这篇–创建于合并分支https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375840038939c291467cc7c747b1810aab2fb8863508000


2018-2-26关闭 pull request(Closing a pull request)

因为pull request错了,所以想取消pull request,怎么做呢? 看图吧

坑不会踩完的,但会一直进步着,大家加油……

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-07-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • git pull时ssh: Could not resolve hostname github.com: Name or service not known, fatal: Could not read from remote repository.
  • git本地仓库首次push到远程仓库出现错误 ! [rejected] master -> master (fetch first)
  • github上传时出现error: src refspec master does not match any
  • fatal: unable to create ‘../../.git/index.lock’:File exists
  • There is no tracking information for the current branch. Please specify which branch you want to merge with.
  • 2018-2-26关闭 pull request(Closing a pull request)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档