碼雲

創建賬號
http://git.oschina.net
windows下使用方法
1.下載gitbash工具
https://git-for-windows.github.io/
2.在上傳的項目根目錄下右鍵打開gitbash
3.全局設置

git config --global user.name "your name"
git config --global user.email "your email"

4.初始化

git init

5.文件本地倉庫上傳

git add README.md a/b.cpp
git commit -m "first commit"

—————————————————————————————————————————————————————————————————————————————
6.建立公鑰

ssh-keygen -t rsa -C "your email"

然後一路回車,這個會在當前用戶文件夾下,生成.ssh 文件夾,裏邊有個 id_rsa.pub文件,用記事本打開,複製其中的全部內容。
然後打開http://git.oschina.net/keys頁面,在該頁面中添加公鑰,標題可以隨便填,公鑰就是剛纔複製過的內容,然後保存即可
測試

ssh -T [email protected]

這個地方 問你yes 還是no 的時候 不要點回車,回車就會失敗了.而是手動輸入 yes才能成功

出現下列warning是正常現象,再一次測試的時候就會通過

The authenticity of host ‘git.oschina.net (120.55.226.24)’ can’t be established.
ECDSA key fingerprint is 27:e5:d3:f7:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘git.oschina.net,120.55.226.24’ (ECDSA) to the list of known hosts.

現在的 ssh 使用同樣的方法會出現錯誤訊息

Agent admitted failure to sign using the key

解決方式 使用 ssh-add 指令將私鑰 加進來 (根據個人的密匙命名不同更改 id_rsa)

ssh-add   ~/.ssh/id_rsa 

再通過ssh 主機名 就可以實現無密碼登錄了。

7.添加遠程倉庫(首先在碼雲上新建一個項目test,之後輸入下列命令)

http方式(每次push都需要密碼):git remote add origin https://git.oschina.net/immo-neu/test.git
ssh方式(push不需要密碼):git remote add origin [email protected]:immo-neu/test.git

8.文件遠程倉庫上傳(前提是已經上傳到本地倉庫)

git push -u origin master

9.不同倉庫下的同步

創建本地倉庫並提交git clone(自動建立倉庫);git add;git commit;
#添加遠程倉庫:git remote add
同步到本地:git pull -u origin master
同步到遠程倉庫:git push -u origin master
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章