Window上傳代碼到github操作指導
阿新 • • 發佈:2017-11-12
ica ash use bject git工具 mas warn soft ini
操作環境
Windows7(32bit)
前提條件
1、完成msysgit工具安裝。下載路徑:官網或百度網盤路徑Git-2.15.0-32-bit.exe。安裝方法為默認選項執行。
2、已註冊github賬戶。假設註冊用戶名為lion123,註冊郵箱為[email protected]
3、本地已創建項目,路徑:E:\SHELL。就是一個文件夾包含需要上傳的文件。
操作步驟
1、選擇"開始" -> "所有程序" -> Git -> Git Bash,進入命令行界面。
2、執行命令 ssh-keygen -t rsa -C "[email protected]" 生成SSH key,全部默認,直接回車。
Administrator@YLMF123-2052250 MINGW32 ~ $ ssh-keygen -t rsa -C "[email protected]" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): Created directory ‘/c/Users/Administrator/.ssh‘. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been savedin /c/Users/Administrator/.ssh/id_rsa. Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub. The key fingerprint is: SHA256:rNxdaz+MMY2R0zbwd8BwRzjRTj47BHhFbhTWBZGYWO4 lion123@163.com The key‘s randomart image is: +---[RSA 2048]----+ | o+=B#B| | .o++X.+| | o=.O | | . .+ *o=| | S E*.o+| | . o . .+..o | | o . . o= .| | ...o | | .. | +----[SHA256]-----+ Administrator@YLMF123-2052250 MINGW32 ~
查看./.ssh目錄下的文件
Administrator@YLMF123-2052250 MINGW32 ~ $ cd .ssh Administrator@YLMF123-2052250 MINGW32 ~/.ssh $ ls -al total 25 drwxr-xr-x 1 Administrator 197121 0 十一 11 07:36 ./ drwxr-xr-x 1 Administrator 197121 0 十一 11 07:35 ../ -rw-r--r-- 1 Administrator 197121 1675 十一 11 07:36 id_rsa -rw-r--r-- 1 Administrator 197121 405 十一 11 07:36 id_rsa.pub Administrator@YLMF123-2052250 MINGW32 ~/.ssh $ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfC4E/GnLVKYKGq1Qp4Apz6n+Smpo9dE1ah50JPIT3C2YDXqOK+MI56kJbmBNyOb7+NTqZzpbvqlkEkKtvohIdN1XgB1u+qsVMtdYlQjTObi4ccHOig+omMgojDAUkoZ5nJz7Ervo0NABiw77AFXmny7UprFIPLZDmFdDeUgF5Vje0zlf9CjzWDk+oHhwuFCkG69gD17o0HgWLbV+EMx2sbHJNYD36cxSb lion123@163.com Administrator@YLMF123-2052250 MINGW32 ~/.ssh
3、登錄github賬戶,打開賬戶下的setting設置,將id_rsa.pub內容復制。
4、校驗本地與GitHub間SSH信任關系
$ ssh -T [email protected] The authenticity of host ‘github.com (192.30.255.112)‘ can‘t be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘github.com,192.30.255.112‘ (RSA) to the list of known hosts. Hi lion123! You‘ve successfully authenticated, but GitHub does not provide shell access.
5、在Github裏新建項目,項目名稱與本地項目文件夾名稱相同(E:\shell),名字為shell。github上創建方法如下
創建完成後可以通過如下方法獲取SSH地址,下面需要用到。
6、在msysgit裏進入本地項目的路徑E:\shell並執行如下相關命令
Administrator@YLMF123-2052250 MINGW32 ~/.ssh $ cd e: Administrator@YLMF123-2052250 MINGW32 /e $ cd shell Administrator@YLMF123-2052250 MINGW32 /e/shell $ git init Initialized empty Git repository in E:/SHELL/.git/ Administrator@YLMF123-2052250 MINGW32 /e/shell (master) $ git add . Administrator@YLMF123-2052250 MINGW32 /e/shell (master) $ git config --global user.email "[email protected]" Administrator@YLMF123-2052250 MINGW32 /e/shell (master) $ git remote add orgin "[email protected]:lion123/Shell.git" Administrator@YLMF123-2052250 MINGW32 /e/shell (master) $ git push -u orgin master Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 2.52 KiB | 859.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To github.com:linyongfeng5555/Shell.git * [new branch] master -> master Branch ‘master‘ set up to track remote branch ‘master‘ from ‘orgin‘. Administrator@YLMF123-2052250 MINGW32 /e/shell (master) $
7、查看github上shell項目是否有本地項目上傳的文件。
8、查看到相關文件,操作完成。
Window上傳代碼到github操作指導