在IntelliJ IDEA中同步程式碼到華為雲git倉庫 (on windows)
阿新 • • 發佈:2019-02-20
在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了,後面就可以專注擼程式碼了。