1. 程式人生 > >Git項目創建與提交

Git項目創建與提交

遠程倉庫 郵箱 ssh-key 成了 tin sha2 rsa perm http

創建Git密鑰:

1、生成密鑰:

右鍵–>Git Bash Here:先輸入ssh-keygen –t rsa –C "郵箱地址",註意ssh-keygen之間是沒有空格的,其他的之間是有空格的,郵箱地址是咱們在註冊GitHub的時候用的郵箱。

生成的密鑰在這裏:C:\Users\Administrator\.ssh

2、將id_rsa.pub用記事本打開,復制裏面全部的內容,放在GitHub的SSH Keys上:

右上頭像箭頭->Settings->左側SSH and GPG keys,New SSH key,粘貼,Add GPG key

3、ssh –T [email protected] 驗證設置是否成功:

Administrator@FEZLIN8TDST7KOF MINGW64 /githere
$ ssh -T [email protected]
The authenticity of host ‘github.com (13.250.177.223)‘ can‘t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes

這裏回復一個yes,而!不!是!習!慣!性!回!車!!

Warning: Permanently added ‘github.com,13.250.177.223‘ (RSA) to the list of known hosts.
Hi Xiaobai0419! You‘ve successfully authenticated, but GitHub does not provide shell access.

這時是在c盤.ssh目錄下多生成了一個known_host文件,再次嘗試命令,成功:

Administrator@FEZLIN8TDST7KOF MINGW64 /githere
$ ssh -T [email protected]
Hi Xiaobai0419! You‘ve successfully authenticated, but GitHub does not provide shell access.

提交項目:

1、切換到項目根目錄,創建本地倉庫(.git隱藏目錄中寫入信息,如果此前有這個目錄,需先整個刪除):

$ git init

2、將目錄下所有文件添加到本地倉庫:

$ git add .

3、提交到本地倉庫,添加註釋:

$ git commit -m ‘dubbo first commit‘

4、添加遠程倉庫地址(需要先在GitHub上建好,復制地址到這裏),命名為origin:

$ git remote add origin https://github.com/Xiaobai0419/minexiaobai0419.git

5、推傳到遠程倉庫:

$ git push -u origin master

Username for ‘https://github.com‘: Xiaobai0419

需要輸入GitHub註冊的用戶名、密碼後確認

6、如果項目已存在於遠程倉庫,要先pull更新,尤其是有在其他點推傳更新的時候:

$ git pull --rebase origin master

7、此後可直接在配置了同一個Git.exe的IDEA中添加、提交、push到遠程倉庫。

Git項目創建與提交