# Git/Github 初心者學習 重點整理 Day 1<br><img alt="GitHub repo file count (file extension)" src="https://img.shields.io/badge/%E5%AD%B8%E7%BF%92%E6%97%A5%E7%A8%8B%20--%202022%2F7%2F15-%20-lightgrey"> ###### tags: `Git/Github` `複習用` `六角學院` `高見龍` >:::spoiler 文章目錄 >[TOC] >::: ## 教材 **Git遠端開發特訓班** [Git & GitHub 教學手冊 - Git 環境教學 | W3HexSchool](https://w3c.hexschool.com/git/cfdbd310) [六角學院 Git - YouTube清單](https://www.youtube.com/watch?v=PNEM7CH3ZAg&list=PLYrA-SsMvTPOZeB6DHvB0ewl3miMf-2tj&ab_channel=%E5%85%AD%E8%A7%92%E5%AD%B8%E9%99%A2) ## 影片內容==重點複習== ### 指令 #### CMD命令提示字元 | Window | 說明 | | -------------------- |:--------------------------- | | cd [路徑] | 前往資料夾路徑 | | mkdir [檔案名稱] | 新增資料夾 | | dir | 顯示資料夾內容 | | code [文件名稱.語言] | 用IDE撰寫code | | code . | 開啟code文件 | | cls | 清除CMD畫面上的內容 | | del | 刪除檔案 | #### Git指令 [在 Windows 中顯示隱藏的檔案、資料夾和副檔名](https://helpx.adobe.com/tw/x-productkb/global/show-hidden-files-folders-extensions.html) | Window | 說明 | | --------------------------------------------------- |:----------------------------------- | | git -v | **顯示git版本** 與 **確認是否安裝** | | git init | **初始化數據庫** | | git config --list | **查詢 git 設定內容** | | git config --global user.name "gon" | **設定姓名** (只要設定一次) | | git config --global user.email "gonsakon@gmail.com" | **設定Email** (只要設定一次) | #### Git流程 ![](https://hackmd.io/_uploads/HJcOdYTic.png) | Window | 說明 | | ---------------------------- |:-------------------------------- | | cd [路徑] | 前往資料夾路徑 | | git init | 初始化數據庫 | | git status | 查詢當前狀態 | | git add . | 將檔案加入到索引 | | git commit -m "說明版本內容" | 將索引檔案,變成一個更新(commit) | | git log (按Q離開) | 觀察 commit 歷史紀錄(更新幾次) | ##### ==自訂義== 簡寫/縮寫 [Git 遠端 Repository 操作 - Quip](https://quip.com/GL4gAFIc2KdI) >**自訂語法撰寫** > `git config --global alias.簡寫 指令語法` > **看config內容是否有改寫** > `git config --list` >**有改寫的** > `git config --global alias.st status` > `git config --global alias.ci commit` > `git config --global alias.co checkout` > `git config --global alias.br branch` | Window | 簡寫/縮寫 | 說明 | |:---------------------------- |:------------------------ |:-------------------------------- | | git status | git st | 查詢當前狀態 | | git commit -m "說明" |git ci -m "說明" |將索引檔案,變成一個更新(commit) || git ci -m "說明版本內容" | ![](https://hackmd.io/_uploads/B1vw166oc.png =700x650) ## 練習建檔與sourcetree運用 ![](https://hackmd.io/_uploads/BkWCFYai5.png) ## 上傳到github遠端數據庫 ### 建立一個New repository ![](https://hackmd.io/_uploads/BJkvWFTs5.png) ### 將本地檔案新增到github > 將下方指令依序輸入 ![](https://hackmd.io/_uploads/HkLTeFps5.png) :::success ```=1 git remote add origin https://github.com/chiaoshin/Git-Github_Learn.git git branch -M main git push -u origin main ``` 1. 將本地數據庫,資料(config)連結到遠端數據庫位址 2. 開一個主要分支 3. 將資料推進去 **(:warning:會要求登入 github帳號密碼)** ::: ### 成功更新檔案 ![](https://hackmd.io/_uploads/S1H6zFajq.png) ![](https://hackmd.io/_uploads/ByIhXFTs9.png) ![](https://hackmd.io/_uploads/HyVg4Fas5.png) ### 建立一個Github page ![](https://hackmd.io/_uploads/Sy794taiq.png) [chiaoshin/Git-Github_Learn: 【Git/Github】新增遠端數據庫(repo)練習](https://github.com/chiaoshin/Git-Github_Learn) ### 再次送到遠端數據庫 1. 利用sourcetree push上去 2. 在命令提示字元輸入 `git push -u origin main` or `git push` :::danger 當 遠端資料庫與本地端衝突時,需要解衝突,將它合併一起。 :paperclip: **在命令提示字元輸入** `git pull --rebase origin main` [解決辦法:git錯誤](https://blog.csdn.net/dietime1943/article/details/85682688) 檔案過大,無法上傳github(100MB限制)。 [Github 超過 100mb 檔案上傳方式 | 一人の旅行記](https://shuwn.dev/2019/09/07/github_%E8%B6%85%E9%81%8E_100mb_%E6%AA%94%E6%A1%88%E4%B8%8A%E5%82%B3%E6%96%B9%E5%BC%8F/) 強制推送,當本地端傳不上去。 [【狀況題】怎麼有時候推不上去... - 為你自己學 Git | 高見龍](https://gitbook.tw/chapters/github/fail-to-push) ::: <img alt="GitHub repo file count (file extension)" src="https://img.shields.io/badge/%E5%AD%B8%E7%BF%92%E6%97%A5%E7%A8%8B%20--%202022%2F7%2F15-Day%201%20-lightgrey"> --- :::spoiler 最後更新日期 >==第一版==[time=2022 7 15 , 12:30 AM][color=#786ff7] >第二版[time=2022 10 25 , 10:30 AM][color=#ce770c] >第三版[time=2022 12 15 , 4:54 PM][color=#ce770c] >第四版[time=2022 12 28 , 7:50 PM][color=#ce770c] >**最後版[time=2022 12 28 , 7:50 PM]**[color=#EA0000] :::