CODE上本地库推送到远程库的问题

来源:互联网 发布:csgo 淘宝版 编辑:程序博客网 时间:2024/06/04 18:00

今天尝试了一下使用CSDN的CODE,公钥私钥生成配置好,新建项目,在本地关联远程库,这里遇到一个问题就是密钥通过不了,是因为邮箱的问题,CODE必须要使用你注册帐号的邮箱去生成密钥才行。修改一下就能关联成功。

但在push的时候又遇到问题。报错如下:

error: failed to push some refs to 'git@code.csdn.net:zhouzhe1991/gittest.git'

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

因为远程仓库的分支比本地的代码要新所以有冲突,原因就是空项目默认创建了一个readme.md文件,那就先把远程库pull下来,执行git pull origin master,还是会报错

fatal: refusing to merge unrelated histories

因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,这句代码是在git 2.9.2版本发生的,但我本地的git版本是2.10,最新的版本需要添加--allow-unrelated-histories

执行:

$ git pull origin master --allow-unrelated-histories

就把远程库拖下来了,接着push就可以了。



0 0