用Github有一两年了,是时候总结一下以前踩得坑了,这些坑开始时还真把自己摔得不轻!!!!! 小插曲:自己以前用hexo搭建的博客,每次写博客都要新建.md文件等初始化步骤,然后提交,有些繁琐,再加上自己又换了台电脑,又要部署hexo(虽然不需要重新部署),但还是有些步骤,索性用简书写,方便快捷些!
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 add .
然后
git commit -m "......"
最后想推送到远程仓库的时候
git push -u origin master
出现下图错误
解决很简单,使用强制推送
使用下面的命令
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. |
---|
如下:
引起该错误的原因是,目录中没有文件,空目录是不能提交上去的
解决方法:先提交文件git add . git commit -m ""
例如下:
1234 | touch READMEgit add README git commit -m 'first commit'git push origin master |
---|
解决方法:把文件index.lock删掉
###Permission denied (publickey). fatal: The remote end hung up unexpectedly
错误原因:github上没有配置公钥 解决方法:配置公钥,并放到github上 GitHub设置公钥在windows下面
Generating public/private rsa key pair. Enter file in which to save the key (/home/forwhat.cn/.ssh/id_rsa): 在这里就是设置存储地址了.反正我是直接按的回车,一直回车
需要注意步骤2中产生的密钥文件在当前用户的根目录,必须把这两个文件放到当前用户目录的“.ssh”目录下才能生效。
————2017/8/14
There is no tracking information for the current branch. Please specify which branch you want to merge with.
是因为本地分支和远程分支没有建立联系 (使用git branch -vv 可以查看本地分支和远程分支的关联关系) .根据命令行提示只需要执行以下命令即可
git branch --set-upstream master origin/master
git branch --set-upstream-to=origin/远程分支的名字 本地分支的名字
git branch –set-upstream-to=origin/develop develop
或
git branch --set-upstream develop origin/develop
(develop为新建分支name)
同时推荐大家看一下下面这篇–创建于合并分支https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375840038939c291467cc7c747b1810aab2fb8863508000
因为pull request错了,所以想取消pull request,怎么做呢? 看图吧
坑不会踩完的,但会一直进步着,大家加油……