git将本地代码首次提交到coding.net远程新建的仓库

知识技术 2022-05-22 10:19 778
转载请务必注明: 来源:《建站管家》https://www.df81.com/news/380.html
1、先初始化本地仓库
git init

2、将本地仓库连接到远程仓库
git remote add origin git@git.coding.net:xxx/xxxxxxxxx.git

3、添加本地代码并提交到本地仓库
git add .
git commit -m "fisrt commit"

4、将本地仓库第一次推送到远程仓库
git push -u origin master

可能出现的错误:
$ git push -u origin master
 
To https://e.coding.net/zyh/xxxxxxxxxxxxxxxxxxxx.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://e.coding.net/zyh/xxxxxxxxxxxxxxxxxxxx.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.

错误信息:

To https://e.coding.net/zyh/xxxxxxxxxxxxxxxxxxxx.git

 ! [rejected]        master -> master (fetch first)

error: failed to push some refs to 'https://e.coding.net/zyh/xxxxxxxxxxxxxxxxxxxx.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.


问题原因:

远程库与本地库不一致造成的,在hint中也有提示把远程库同步到本地库就可以了。

执行如下命令即可

git pull --rebase origin master

该命令的意思是把远程库中的更新合并到(pull=fetch+merge)本地库中,–-rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。出现如下图执行pull执行成功后,可以成功执行git push origin master操作。

点赞 (0)

收藏 (0)

本站部分信息来源网络,如有侵权,请联系QQ:1062129401删除。

上一篇: 《建站管家》二次开发文档

下一篇: python模拟header报错:AttributeError: 'set' object has no attribute 'items'

请先登录后,再发表评论 ~ ~
发表评论
发表评论
发表帖子
广告位招租( ¥5 / 天 )
点击咨询
相关帖子

如果要判断文件是否存在,用函数 is_file(),如果要判断目录是否存在,用函数 is_dir()
用宝塔安装TP程序后,网站前台可以访问,后台无法访问,不是程序问题,而是web服务器环境配置问题(PHP配置),出现这种问题,一般是windows主机安装宝塔造成的,linux安装宝塔不会出现此错误
广告位招租( ¥3 / 天 )
点击咨询
广告位招租( ¥2 / 天 )
点击咨询
广告位招租( ¥1 / 天 )
点击咨询
最新帖子

小朋友,你爸爸是谁啊?这很单纯的,就像我们碰到别人会问:你吃过饭了吗?类似;许多人初次相识,经常会问:你是做什么的啊?你做什么,好像决定你收入的高低,你,资产的范围
1、升级框架到ThinkPHP8.0.3【要求PHP8.1+环境,推荐PHP8.1】 2、启用/禁用调试模式等小细节改进
后台点击生成站点地图 一直转圈圈没有反应,
在线客服