初始條件,先自行建好gitlab的代碼倉庫和碼云的代碼倉庫,ssh配好。
-
打開gitlab項目,在左側菜單欄選擇
Settings->Repository
gitlab項目 -
選擇Push to a remote repository,打開之后可以看到相關的配置信息。
配置 勾選Remote mirror repository
填寫Git repository URL:這個URL地址就是你在碼云或者github上面創建的項目的ssh地址,不過需要在地址里加上你的碼云或者github的賬號密碼。
比如:
我在碼云的賬號:userName
密碼:password
項目地址:https://gitee.com/FutaoSmile/SpringCloud-ServiceRegisterCenter.git
那么這個地址應該相應的改成這樣:
https://userName:password@gitee.com/FutaoSmile/SpringCloud-ServiceRegisterCenter.git
密碼和地址之間有一個@
符號。
- 測試:提交一次push到gitlab之后,gitlab會幫我們自動push代碼到我們所配置的遠程倉庫。