一.配置本地Git庫
1.下載安裝好Git,並配置自己的信息。
git config --global user.name"yourname"配置你的名稱
git config --global user.mail"youemail@email.com"配置你的郵箱

如果想修改上一步輸的入user.name和user.mail,可用 git config --replace-all user.mail(user.name)修改user,.name和user.mail

2設置自己的git庫並存儲文件
首先進入自己所選的文件夾
cd /f f為你所選的文件夾地址
git init 將現所在地址設為Git庫
git add filename 添加文件(fileame需要帶格式名)
git add . 添加文件夾內的所有文件
git commit -m "" ""內是注釋,如為空會報錯

git log -prett=oneline 以單行形式查看庫信息。
重復 git add git commit 形成多個歷史版本的Git庫

當你想回退到某一個版本時,使用
git reser --hard **** ****為版本號前4位字符

二.本地Git庫與Github之間的傳輸
本地Git庫和Github庫之間的傳輸是通過SSH加密的,所以在進行傳輸之前需要設置SSH Key這里默認用戶沒有設置過SSH Key。(如若在C:\Users\Ltp\.ssh 有id_rsa和id_rsa.pub即為有設置過SSH Key 可跳過下一步)
在Git中輸入
ssh-keygen -t rsa -C "youremail@mail.com" yourmail@mail.com為你的github郵箱 然后經歷3次回車即可完成SSH Key設置,設置完成后的C:\Users\Ltp\.ssh就會出現你的id_rsa和id_rsa.pub文件

然后登陸 Github,點擊右上角用戶頭像,再點擊Seetings,在新的頁面中點擊左下方的SSH and GPG KEYS,在點擊右上角的 New SSH key,將你的id_rsa.pub文件中的所有內容填入到出現的KEY選項中去,Title可以隨便填,然后點擊add SSH key即可完成。



在本地Git中輸入 git remote add origin https://github.com/kdaysl/my-python.git origin后為你的github庫地址。
如若在這一步出現 fatal: remote origin already exists. 可輸入git remote rm origin 清除信息,然后再進行上一步的add origin操作。

之后即可進行本地Git庫的上傳
git push origin master 上傳本地庫文件,如果是首次上傳 則改用git push -u origin master 在接下來的步驟中輸入你的github用戶名以及密碼即可上傳。

之后在github中即可看到上傳的本地庫文件

本次應用的github庫地址:https://github.com/kdaysl/my-python

