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

南国老符 南国老符 最后更新于:2022-05-22 浏览:1017
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)
转载请务必注明: 来源:《建站管家》https://www.df81.com/news/380.html

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

上一篇: git报错protocol "https" is not supported的解决方法

下一篇: 就在刚刚,我化解了一场,即将发生的打斗

请先登录后,再发表评论 ~ ~
发表评论
评论 (0)

发表帖子
广告位招租( ¥5 / 天 )
点击咨询
最新帖子

南国老符
2025-05-26 16:54
南国老符
2024-09-29 10:29
南国老符
2023-12-15 21:41
广告位招租( ¥5 / 天 )
点击咨询
最近评论

U
user1379
回复:版本号多少?
U
user1379
回复:新版本修复了,下载新版本即可
U
user1379
U
user1304
回复:默认没有这个功能,你可以自行二次开发后期可能会考虑在站群版本上加入此功能及商城功能
Y
yuanis90
回复:后台->语言->全局管理->模型管理->编辑->启用关键词内链即可
Y
yuanis90
回复:后台已经启用了,但是前台产品说明的关分键词还是没有自动链接到,
购买VIP
购买授权
余额充值
发表帖子
客服微信