在IntelliJ IDEA中同步代码到华为云git仓库 (on windows)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/stanxl/article/details/78739443

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

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

这里写图片描述

结束之后Alt+F12在IDEA中找开终端,先把华为云上的git仓库pull下来,我在华为云上创建了一个测试用的仓库:[email protected]: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 <name> <url>

and then push using the remote name

    git push <name>

所以它给的提示很明确,把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了,后面就可以专注撸代码了。

猜你喜欢

转载自blog.csdn.net/stanxl/article/details/78739443