git配置教程


一.配置ssh

1.檢查本機是否有ssh key設置

如果沒有則提示: No such file or directory
如果有則進入~/.ssh路徑下(ls查看當前路徑文件,rm刪除所有文件)

2.使用Git Bash生成新的ssh key

$ cd ~ #保證當前路徑在”~”下

$ ssh-keygen -t rsa -C "xxxxxx@yy.com"  #建議填寫自己真實有效的郵箱地址
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa):   #不填直接回車
Enter passphrase (empty for no passphrase):   #輸入密碼(可以為空)
Enter same passphrase again:   #再次確認密碼(可以為空)
Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa.   #生成的密鑰
Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub. #生成的公鑰
The key fingerprint is:
e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 xxxxxx@yy.com
//本機已完成ssh key設置,其存放路徑為:c:/Users/xxxx_000/.ssh/下。
//可生成ssh key自定義名稱的密鑰,默認id_rsa。
$ ssh-keygen -t rsa -C "郵箱地址" -f ~/.ssh/githug_blog_keys #生成ssh key的名稱為githug_blog_keys,慎用容易出現其它異常。

3.添加ssh key到GItHub

3.1 登錄GitHub系統;

點擊右上角賬號頭像的“▼”→Settings→SSH kyes→Add SSH key。

3.2 復制id_rsa.pub的公鑰內容

  1. 進入c:/Users/xxxx_000/.ssh/目錄下,打開id_rsa.pub文件,全選復制公鑰內容。
  2. Title自定義,將公鑰粘貼到GitHub中Add an SSH key的key輸入框,最后“AddKey”。

4.配置賬戶

$ git config --global user.name “your_username” #設置用戶名
$ git config --global user.email “your_registered_github_Email” #設置郵箱地址(建議用注冊giuhub的郵箱)

5.測試ssh keys是否設置成功

$ ssh -T git@github.com
The authenticity of host 'github.com(192.30.252.129)' can't be established.
RSA key fingerprint is16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.
Are you sure you want to continueconnecting (yes/no)? yes #確認你是否繼續聯系,輸入yes
Warning: Permanently added'github.com,192.30.252.129' (RSA) to the list of known hosts.
Enter passphrase for key'/c/Users/xxxx_000/.ssh/id_rsa': #生成sshkye是密碼為空則無此項,若設置有密碼則有此項且,輸入生成ssh key時設置的密碼即可。
Hi xxx! You've successfullyauthenticated, but GitHub does not provide shell access. #出現詞句話,說明設置成功。

二、Github新建項目

1.Github新建項目

2.注意項目名(必須是:github的用戶名.github.io)

3.clone項目地址

4.將項目clone到本地

然后輸入命令,回車,等待clone完成。

5.將index.html推送到遠程github倉庫中

git add .
git commit -m "這里是注釋信息,自己寫"
git push origin master

寫在最后

github配置好了,就可以本地新建git項目,然后上傳到github上了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM