git遇到的一点小问题

今天使用androidstudio将做了一段时间的小项目上传到git。

在android studio中创建仓库,然后进入文件夹。命令行中

git   remote add ###添加远程仓库

然后add

commit

push(如果忘了add commit直接push也是会报错的。)

然后

git push -u origin master

提示下面错误:

--ssh: Could not resolve hostname ssh.github.com: Name or service not known


我查看了一下配置。也没有什么问题。后来思考了一下,无法解析很有可能是dns解析的问题

看了一下我的dns原来是服务器课程设计时配置为固定的虚拟机dns解析 ip忘记改回来。

这边改为自动获取就可以了。

但是却又出现了新的报错:

error: failed to push some refs to 'git@git.oschina.net:ningbo1222/CollegeLife.g                                                        it'
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.

对于这个问题,很明显提示需要pull一下,

通过查询

可以通过如下命令进行代码合并【注:pull=fetch+merge]

git pull --rebase origin master


执行后在执行push,果然成功了。



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值