华为云Git仓库操作,将本地代码上传到CodeHub

华为云Git将本地代码上传到CodeHub

在DevCloud代码托管服务中,创建一个空仓库。

不选择“选择gitignore”。

勾选“允许生成README文件”。

在本地,准备好将要上传的源代码。

如果原来是来自SVN服务器的,建议参考 将SVN代码库迁移到Git代码库。

如果原来没有纳入过任何的版本系统,则在源代码的根目录,执行以下git命令(以Git Bash为例):

  1. 初始化Git仓库
git init
  1. 将文件加入版本库
git add *# *表示讲当前文件夹下所有add到版本库
  1. 创建初始提交:
git commit -m "init commit"
  1. 设置本地仓库的远程服务器地址:
  • 如果原来从其它地方clone的git仓库,则添加一个新的remote,命令行参考如下:
git remote add new git@***.***.com:testtransfer/Repo1.git      ——(new 后面为仓库地址)
  • 如果是一个刚刚初始化的仓库,则添加一个名为origin的remote,命令行参考如下:
git remote add origin git@***.***.com:testtransfer/Repo1.git    ——(origin 后面为仓库地址)
  1. 推送全部代码到远端仓库:
git push new master      (对应步骤3的第一种情况)
git push origin master   (对应步骤3的第二种情况)

容易遇见的问题

1、问题1

error: failed to push some refs to 'git@github.com:yangchao0718/cocos2d.git
hint: Updates were rejected because the tip of your current branch is behin
hint: its remote counterpart. Integrate the remote changes

解决:

git pull --rebase origin master

2、问题2

$ git remote add origin git@codehub.devcloud.cn-north-4.huaweicloud.com:hzcz-zsjjd2018jjava2b-6b00001/Git-SMM_hzc.git
fatal: remote origin already exists.

解决:

 1、先输入 $ git remote rm origin2、再输入 $ git remote add origin git@***.***.com:testtransfer/Repo1.git    ——(origin 后面为仓库地址) 就不会报错了!3、最后再 $ git push origin master (参考上面第4点)


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部