idea怎么把代码放到git_在IntelliJ IDEA中同步代码到华为云git仓库 (on windows)

本文介绍了如何在Windows环境下使用IntelliJ IDEA将代码同步到华为云Git仓库。通过创建Git仓库,拉取远程仓库并解决push失败的问题,最终成功将代码推送到华为云。
摘要由CSDN通过智能技术生成

在IntelliJ IDEA中同步代码到华为云代码仓库和同步到github中差不多,只是两个不同的代码托管平台,公司现在让把源码放到华为云上,捯饬了一会,捋一下步骤。

假如你在IDEA中创建了一个maven项目,叫ideaToHuaWeiCloud,并以这个项目所在目录创建一个git仓库:

结束之后Alt+F12在IDEA中找开终端,先把华为云上的git仓库pull下来,我在华为云上创建了一个测试用的仓库:git@codehub.devcloud.huaweicloud.com:19ce962b186c43b19d1d7786015239c1/testingDraft.git

git pull git@codehub.devcloud.huaweicloud.com:19ce962b186c43b19d1d7786015239c1/testingDraft.git --allow-unrelated-histories

注意后面加上--allow-unrelated-histories,不然pull不下来,然后就可以看到README.md 就被pull 到项目中了,现在修改下README.md然后再push到华为云上,就出现了:

C:\Users\Administrator\IdeaProjects\ideaToHuaWeiClouds>git push origin master

fatal: 'origin' does not appear to be a git repository

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

出现了这个问题,怎么办呢,如果只是git push看看有什么提示:

C:\Users\Administrator\IdeaProjects\ideaToHuaWeiClouds>git push

fatal: No configured push destination.

Either specify the URL from the command-line or configure a remote repository using

git remote add

and then push using the remote name

git push

所以它给的提示很明确,把remote repo加上去:

C:\Users\Administrator\IdeaProjects\ideaToHuaWeiClouds>git remote add testing git@codehub.devcloud.huaweicloud.com:19ce962b186c43b19d1d7786015239c1/testingDraft.git

而后:

C:\Users\Administrator\IdeaProjects\ideaToHuaWeiClouds>git push testing master

Counting objects: 11, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (10/10), done.

Writing objects: 100% (11/11), 4.88 KiB | 1.63 MiB/s, done.

Total 11 (delta 0), reused 0 (delta 0)

To codehub.devcloud.huaweicloud.com:19ce962b186c43b19d1d7786015239c1/testingDraft.git

03dc590..9120f86 master -> master

就可以看到push成功了,README.md中的push to cloud就是我后面加上去的:

ok了,基本的准备就都OK了,后面就可以专注撸代码了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值