Git的安裝和使用(託管至GitHub的方法)
一、下載Git
1.下載
下載地址:
https://git-scm.com/download/win
根據你的作業系統選擇32位或者64位
2.安裝過程一路next
3.檢驗安裝是否成功
在桌面點選右鍵,如果出現這兩個選項代表安裝成功
二、Git初始化及使用
1.點選右鍵選擇 Git Bash Here
輸入以下命令:
git config -- global user.name '你的使用者名稱';
git config -- global user.email '你的郵箱';
2.配置後可以輸入此條命令看是否設定成功
git config --list
3.建立本地倉庫
建立一個資料夾,用作你的倉庫
開啟這個資料夾,在這個目錄下右鍵,選擇Git Bash Here
輸入此條命令:
git init

4.然後資料夾中會出現一個.git的資料夾
該資料夾屬性為隱藏
5.將你的專案複製到此資料夾中
6.將檔案提交到緩衝區
執行以下命令
git status
發現飄紅了,這是因為我們沒有將檔案提交到快取區
使用這條命令可將所有檔案提交到緩衝區
注意:add 與 . 之間有一個空格,代表目錄下的所有檔案,如果只提交一個檔案,也可以輸入這個檔案的檔名
git add .
再次使用
git status
綠色就很舒服~
6.將緩衝區檔案提交到本地倉庫
輸入命令:
git commit -m "你的備註"

二、將專案託管至GitHub
1.建立GitHub賬號
地址:https://github.com/
2.點選右上角頭像,選擇your profile
3.建立專案
4.回到之前的本地倉庫資料夾
執行之前說過的命令
git add .
git commit -m "你的備註"
然後下面這條使用之前讓你記住的地址
git remote add origin https://github.com/....
如果是第一次就執行
git push -u origin master
如果不是第一次,是上傳更新後的程式碼就執行
git push origin master
5.在GitHub上可以看到專案檔案和提交記錄了
最後我把命令都彙總了一下,方便使用
git config --global user.name ""
git config --global user.email ""
git init git add . git status
git remote add origin https://github.com/....
git commit -m "" git push -u origin master
git push origin master
原文釋出時間為:2018-10-22
本文作者:chestnut_egg
本文來自雲棲社群合作伙伴“ ofollow,noindex">Python愛好者社群 ”,瞭解相關資訊可以關注“ Python愛好者社群 ”。