本地现有项目关联github

背景:我们在本地已经开发了一些项目,此时需要在github上创建相对应的项目

首先在github上new一个仓库

接着输入仓库名,然后点击创建即可。

创建完一个空项目,github会给出提示告诉我们怎么关联,只要把其中一种代码拷贝执行即可

——————————————————————————————————————————————————————

如果在创建仓库时已经初始化过项目,系统则会给出报错

error: failed to push some refs to 'https://github.com/xxx/test.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/xxx/test
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

说这两个库的git历史记录不相干而无法合并,这时我们可以加上一个参数 --allow-unrelated-histories 即可成功pull: 

git pull origin master --allow-unrelated-histories

之后便可正常使用了

——————————————————————————————————————————————————————

当第一次使用Git的clone或者push命令连接GitHub时,会得到一个警告: 

The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?

这是因为Git使用SSH连接,而SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入yes回车即可。之后Git会输出一个警告,告诉你已经把GitHub的Key添加到本机的一个信任列表里了。这个警告只会出现一次,后续的操作不会报这样的警告了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值