1. 程式人生 > >git使用碼雲遠端庫

git使用碼雲遠端庫

首先你得註冊碼雲使用者,然後在碼雲平臺開始建立一個專案.
https://gitee.com/sharps/springcloud.git

一、初始化空的 Git 倉庫於 /home/sharps/IdeaProjects/springcloud/.git/

sharps@sharps-computer:~/IdeaProjects/springcloud$ git init

二、在該目錄下建立檔案,通過下面兩條指令將檔案提交到.git 目錄裡的倉庫配置資訊裡面

sharps@sharps-computer:~/IdeaProjects/springcloud$ git add .
sharps@sharps
-computer:~/IdeaProjects/springcloud$ git commit -m 'first commit!'

三、建立遠端庫的配置資訊

sharps@sharps-computer:~/IdeaProjects/springcloud$ git remote add origin https://gitee.com/sharps/springcloud.git

origin 為本地遠端倉庫地址代號,以後pull push 可以簡寫。
如果新增遠端庫的這一步出現問題,你可以 git remote -v檢視你的遠端庫名是不是已經被使用了,你可以選擇重新取另外一個名字,或者 git remote rm 遠端庫名刪除這個名字,再重新執行第三步內容

四、已有的專案PUSH到倉庫。養成好習慣,不管這個專案多少人蔘與,push之前先pull一下,看看有沒有merge的程式碼,有merge解決merge,沒有的話直接下面的命令

[email protected]:~/IdeaProjects/springcloud$ git pull origin master
[email protected]:~/IdeaProjects/springcloud$ git push -u origin master

其他命令:
[email protected]:~/IdeaProjects/springcloud$ git status #檢視

[email protected]:~/IdeaProjects/springcloud$ git clone 專案的https地址
[email protected]:~/IdeaProjects/springcloud$ git rm -r origin
[email protected]:~/IdeaProjects/springcloud$ git remote -v