本文不闡述任何概念性知識,僅僅只是做一個筆記,簡單的使用步驟,如遇障礙,請Google一下

  1. 生成 SSH key
PLAINTEXT
ssh-keygen -t rsa
クリックして展開し、詳細を表示

指定 RSA 演算法生成金鑰,之後就會生成兩個檔案,分別為id_rsa和id_rsa.pub,即私鑰id_rsa和公鑰id_rsa.pub。對於這兩個檔案

  1. 添加 SSH key github.com -> Settings -> SSH and GPG -> New SSH key 將公鑰id_rsa.pub的內容貼到Key處的位置(Titles的內容不填寫也沒關係),然後點擊Add SSH key 即可。

  2. 驗證綁定是否成功

PLAINTEXT
ssh -T git@github.com
クリックして展開し、詳細を表示

(1) 打開你的目錄

PLAINTEXT
cd demo
クリックして展開し、詳細を表示

(2) 初始化版本庫,用於生成git檔案

PLAINTEXT
git init
クリックして展開し、詳細を表示

(3) 將所有檔案添加到暫存區

PLAINTEXT
git add *
クリックして展開し、詳細を表示

(4) 提交目前工作空間的修改內容

PLAINTEXT
git commit -m "first commit"
クリックして展開し、詳細を表示

(5) 將儲存庫連接到遠端伺服器

PLAINTEXT
git remote add origin <server>(就是上面你儲存庫的地址)
クリックして展開し、詳細を表示

(6) 將改動推送到所添加的伺服器上

PLAINTEXT
git push -u origin master
クリックして展開し、詳細を表示

在推送的時候如果出現如下錯誤:

PLAINTEXT
warning: redirecting to https://github.com/178146582/dabai.git/
To http://github.com/178146582/dabai.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'http://github.com/178146582/dabai.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
クリックして展開し、詳細を表示

查了一下錯誤的原因是github中的README.md檔案不在本地程式碼目錄中。所以我們把上面第六步分成兩步:

PLAINTEXT
git pull --rebase origin master:進行程式碼合併
クリックして展開し、詳細を表示
PLAINTEXT
git push -u origin master
クリックして展開し、詳細を表示

著作権表示

著者: MoeJue

リンク: https://ja.moejue.cn/zh-hant/posts/64/

ライセンス: クリエイティブ・コモンズ表示-非営利-継承4.0国際ライセンス

この作品は、クリエイティブ・コモンズ表示-非営利-継承4.0国際ライセンスに基づいてライセンスされています。

検索を開始

キーワードを入力して記事を検索

↑↓
ESC
⌘K ショートカット