本地推送到远程库 异常
Topic source廖老师是通过 git@github.com:michaelliao/learngit.git 关联的,我在win7和win10上测试推送时都不能成功,https的才可以。如果已经用git@关联,则可以在.git目录下的config文件中,把 url = 后面的内容改为https类型的即可。 https类型的格式为: $ git remote add origin https://github.com/daoke0818/testGit2.git
另外我发现:
如果在第一步中创建时已经初始化过项目,则这时会提醒 error: failed to push some refs to 'https://github.com/daoke0818/testGit2.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. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
因为远程库中已经存在readme文件了,所以需要先pull下来。命令如下: $ git pull origin master
这时又会报错: From https://github.com/daoke0818/testGit
- branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories
说这两个库有不相干的历史记录而无法合并,这时我们可以加上一个参数 --allow-unrelated-histories 即可成功pull: $ git pull origin master --allow-unrelated-histories
但是这时会可能会提示必须输入提交的信息,默认会打开vim编辑器,先按 i 切换到插入模式,写完后 Esc→:→wq 即可保存退出编辑器。如果不进入vim编辑器,则会自动生成一个合并代码的commit。然后再使用前面的命令push将本地提交推送到远程仓库。后面如果本地还有commit,就可以直接用 git push origin master 推送。
以上来自我的笔记: 文档:git学习(廖雪峰版教程).note 链接:http://note.youdao.com/noteshare?id=4653994abae090b764e7fb65a039a7fe&sub=4B72DD531A444C5E97EB28F6A969D01D
我的是报错ssh: could not resolve hostname github,coam: nodename nor servname provided,
把.git下的config文件中的url参数改成https的就行了
- 1
我姓陈19940924
$ git push -u origin master Logon failed, use ctrl+c to cancel basic credential prompt. Username for 'https://github.com':
这个错误怎么处理啊 弹出一个登陆框 登陆了还是不行