<style> .reveal { font-size: 24px; } </style> # GIT 版本控制 #### Rice --- ## 開始前請大家 1. 在電腦上安裝 Git - windows: [git for windows](https://gitforwindows.org/) - ubuntu: `sudo apt install git` 2. 至 github.com 註冊帳號 --- ## 如果不用 GIT... ---- ![](https://i.imgur.com/MJEgwKn.png) ---- ![](https://i.imgur.com/bNNT3lK.png) ---- ![](https://i.imgur.com/9FugHra.png) --- # 版本控制 ---- ### 本地端版本控制 ![](https://i.imgur.com/UcORn1Z.png) ---- ### 集中式版本控制 ![](https://i.imgur.com/J8sZjXW.png) ---- ### 分散式版本控制 ![](https://i.imgur.com/qu2WbnQ.png) --- ## 環境設置 - git config --global user.email "you@example.com" - git config --global user.name "Your Name" - git config --global core.editor notepad ---- ## 其他 - git config --global color.ui true - git config --global alias.lg "log --oneline" --- ## GitHub <del>世界最大男性交友平台</del> Code 倉庫 (Create / Delete) ---- ## 福利 [Sudent Develop Pack](https://education.github.com/pack) --- ## 開始版本控制吧! git init ---- ## 建立檔案 touch readme.md --- ## 新增檔案 git status ---- ## 觀念 ![](https://i.imgur.com/FYc5Vcb.png) ---- - git add readme.md - git add . ---- git reset readme.md --- ## 提交檔案 ![](https://i.imgur.com/FYc5Vcb.png) ---- ## Before commit - git status - git diff - git diff --cached ---- ## Commit - git commit - git commit -m "My first commit" ---- ## Commit 時機 看個人風格和公司需求 <del>沒事多 commit,多 commit 沒事</del> ---- ## Commit Message 怎麼寫 [不良範例](https://i.imgur.com/JVKpcD4.png) ---- ## 查看歷史紀錄 - git log - git lg - git config --global alias.lg "log --oneline" ## 歷史紀錄 ![](https://i.imgur.com/t0BYwCz.png) ---- ## Remove file git rm \<file> ## Untrack file git rm \<file> --cached ---- ## Rename file git mv \<file> \<new_name> --- ## 回到過去 git checkout git branch -f master ---- ## 暫存 - git stash - git stash save - git stash list - git stash pop ---- ## 回到過去保留現在 - git reset - git reset --hard ---- ## 回到過去保留現在留下紀錄 - git revert --- ## 所以那個 GitHub 呢 ![](https://i.imgur.com/ytixb5p.png) ---- ## 遠端 - git remote add origin \<GitHub repo link> - git remote - git remote -v ---- ## 推送 - git push -u origin master - git push - [push.default](http://stackoverflow.com/a/13148313) --- ## Branch ![](https://i.imgur.com/V8DphfC.png) ---- ## List Branchs - git branch - git branch -a - git branch -v - git branch -vv - git branch -d ---- ## Create gh-pages 1. git branch gh-pages 2. git checkout 3. git push -u origin gh-pages ---- ## 進入網址 \<username>/github.io/\<repo name> (可能要等一下) --- ## 合併分支 - git merge \<branch> - git rebase \<branch> --- ## 其他重要的指令 - git clone - git fork - git pull - git commit --amend - git blame - git cherry-pick - git bisect --- # Thanks!
{"metaMigratedAt":"2023-06-15T13:55:15.408Z","metaMigratedFrom":"YAML","title":"GIT 版本控制","breaks":true,"slideOptions":"{\"theme\":\"moon\",\"transition\":\"fade\"}","contributors":"[{\"id\":\"30a8feb1-7635-4e18-9daa-0fa53b4cc8f5\",\"add\":2832,\"del\":87}]"}
    511 views