Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Git 教學簡報
Search
Denix
September 14, 2017
Programming
0
260
Git 教學簡報
CMRDB Workshop - Git
Denix
September 14, 2017
Tweet
Share
More Decks by Denix
See All by Denix
Android_Scalable_Modularized_Testable_Architecture.pdf
denishsieh
0
270
Learning Android
denishsieh
0
44
你所不知道所得分配的事
denishsieh
0
67
Database 教學簡報
denishsieh
0
64
Other Decks in Programming
See All in Programming
Serena MCPのすすめ
wadakatu
4
980
Foundation Modelsを実装日本語学習アプリを作ってみた!
hypebeans
0
110
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
520
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
100
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
2
820
その面倒な作業、「Dart」にやらせませんか? Flutter開発者のための業務効率化
yordgenome03
1
120
Web Components で実現する Hotwire とフロントエンドフレームワークの橋渡し / Bridging with Web Components
da1chi
3
2.1k
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1.3k
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
4
2k
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
PHPに関数型の魂を宿す〜PHP 8.5 で実現する堅牢なコードとは〜 #phpcon_hiroshima / phpcon-hiroshima-2025
shogogg
1
160
私はどうやって技術力を上げたのか
yusukebe
43
18k
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Fireside Chat
paigeccino
40
3.7k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
How STYLIGHT went responsive
nonsquared
100
5.8k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
It's Worth the Effort
3n
187
28k
Transcript
CMRDB 靜宜大學行雲者研發基地 CMRDB workshop Git 講者: 資工四B 謝宗翰 2015/07/18
2 outline ◎前言 ◎安裝設定 ◎基礎概念 ◎實作練習 ◎Q&A
3 前言
4 Git是什麼? 看到不爽的人就可以說: 你這個…
5 我要說的git其實是… VERSION CONTROL 版本控制 版本管理 管理程式碼 分散式架構 多人協同合作 不同時間
不同地點
6 誰創造了Git ◎Git作者: Linus Torvalds ◎Linux kernel創始人 ◎程式碼超過1000萬行(2008) ◎為了管理Linux內核的原始碼需要好方法 GIT神猛啊~
7 Git的命名 ◎Linus說: “我是一個自負的混蛋。我命名了自 己所有的專案,第一個是Linux,現在是Git” ◎Git: 英國俚語,混帳。 ◎Git意味著什麼取決於你的心情 Ø 可讀的三個隨機字母的組合,而且沒有被UNIX的
指令用過。事實上,這可能是get的錯誤發音 Ø Stupid. Contemptible and despicable. Simple. Take your pick from the dictionary of slang. Ø ……Git官方wiki
8 為什麼要用Git ◎避免程式碼被改爛 ◎參考連結
9 安裝設定
10 安裝 ◎Windows Ø 請至git官網下載安裝包並執行,下一步到底!! ◎Linux Ø Ubuntu: $sudo apt-get
install git ◎Mac Ø 請至官網下載安裝包並執行
11 設定 ◎打開Git bash ◎下指令 Ø git config –global user.email
“your email address” Ø git config –global user.name “your name”
12 熟悉一下Linux的指令列操作 ◎$cd Ø Change directory: 變更目錄 Ø $cd [資料夾名稱]
ü 到此目錄下的某個目錄 Ø $cd .. ü 回上層目錄 ◎$ls Ø list directory contents: 列出目錄內容 ◎$cat .gitconfig Ø 將檔案內容抓取出來
13 GIT基礎概念
14 三個狀態 工作區域 準備區域 (暫存區) 容器 鍋子 流理臺 氈板 下鍋就生米煮成熟飯囉!
15 分支概念 創造分支就像細胞分裂 點就是下鍋的紀錄! 開發人員會有一條以上的分支
16 分散式概念
17 常用基礎指令 ◎$git init Ø 初始化(initial) ◎$git add ./[file name]
Ø 將該目錄下的一切/檔案加入追蹤 ◎$git commit Ø 將目前狀態提交進入容器裡 ◎$git clone [address] Ø 將遠端容器裡的專案複製下來
18 常用基礎指令1 ◎$git pull Ø 將遠端容器狀態更新到本地端 ◎$git push Ø 將新的提交推到遠端分支
◎$git branch [branch name] Ø 產生新的分支 ◎$git checkout [branch name/ commit hash] Ø 狀態轉換至該分支或者是某個提交的狀態
19 常用基礎指令2 ◎$git merge [branch name] Ø 將某分支合併入目前所在分支 ◎$git reset
HEAD [file name] Ø 取消已被暫存的檔案 ◎$git commit --amend Ø 更動最後一筆更新 ◎$git status Ø 查看目前狀態
20 常用基礎指令3 ◎$git log Ø 查看提交紀錄 ◎$git rm [file name]
Ø 刪除某個被追蹤的檔案 ◎$git show Ø 查看特定版本 ◎$git diff Ø 查看差異
21 人畜無害的指令 ◎$git status Ø 查看狀態 ◎$git log (-- graph)
Ø 查看提交紀錄 ◎$git show [commit hash] Ø 查看特定版本 ◎$git diff Ø 查看差異
22 小練習1 ◎嘗試初始化一個git容 器 Ø 1.新增一個資料夾 Ø 2.變更目錄到該資料夾 ü $cd
[folder name] Ø 3.初始化 ü $git init Ø 4.新增檔案並使用add 指令 ü $git add ./[file name] Ø 5.Add完後試試看 commit ü $git commit Ø 6.重複步驟4跟5幾次 Ø 7.一邊做一邊試試看人 畜無害指令! status show log diff 小提示:在提交的時候會進入vim文字編輯器。 先按鍵盤上的i鍵,進入編輯模式, 然後輸入你的提交訊息! 完成後按ESC然後打:wq
23 小練習2 ◎新增一個分支 Ø $git branch [branch name] Ø 使用checkout跳躍分支
ü $git checkout [branch name] Ø 在其一分支當中做修改完 ü $git add . ü $git commit ü $git log ü $git diff
24 git status
25 git show
26 提交紀錄git log c480fdeb2ec……………………… 透過一種加密演算法得來 極難重複 每個提交紀錄都會有這樣的雜湊
27 git diff 比較任兩點 間的差異!
28 實作練習
29 Bitbucket ◎雲端代碼託管服務:遠端容器 ◎先申請一個帳號 ◎使用git bash產生一組ssh金鑰 Ø $ssh-keygen –t rsa
◎將id_rsa.pub內容貼至bitbucket個人帳號內 Ø $cd .ssh Ø $cat id_rsa.pub
30 操作步驟1 ◎下載遠端容器內容 Ø 至你想放置該專案的位置使用此指令 ü $git clone [address] ◎產生自己的分支
Ø $git branch [branch name] ◎切換到自己的分支上 Ø $git checkout [branch name] ◎推送本地分支到遠端容器 Ø $git push origin [branch name]
31 操作步驟2 ◎嘗試在自己的分支做些變更(新增一個檔案…) ◎做完之後將變更暫存起來 Ø $git status Ø $git add
[filename]/. ◎進行提交動作 Ø $git status Ø $git commit Ø 輸入提交訊息 ◎查看狀態還有紀錄 Ø $git status Ø $git log
32 什麼時候要做提交? ◎通常當工作到一個階段的時候 ◎例如:完成一個功能or…(function, class……) ◎Do commit early and often
其實你想提交就提交啊!
33 提交訊息要怎麼寫? ◎沒有一定規範 ◎清楚描述一個階段裡的工作 ◎避免無意義的描述
34 如果想要修改提交訊息? ◎剛做完一個commit發現字打錯了或者是漏 打一些訊息,要怎麼辦? ◎$git commit --amend
35 放棄變更 ◎剛把新的程式碼加入追蹤(add),可是後來發 現隊友已經做過這個功能了,所以剛才打 的已經不需要了,要怎麼辦?手動刪除嗎? ◎$git reset HEAD [file name]
36 操作步驟3 ◎更新提交至遠端容器,看看bitbucket Ø $git push ◎嘗試將別人的分支拉下來 Ø $git fetch
◎跳到別人的分支看看 Ø $git checkout [branch name] ◎合併別人的分支 Ø $git merge [branch name] ◎看看工作目錄!
37 操作步驟4 ◎回到之前的狀態 Ø $git checkout [commit hash] ◎刪掉一些檔案試試看 Ø
先手動操作 Ø $git status Ø $git rm [file name] 自己玩玩看!
38 每次都要打很長的指令好煩! alias: 別名
39 分散式工作流程 advanced
40 集中式工作流
41 集成管理員工作流
42 司令官與副官工作流 司令官 副官
43 Conclusion 小程式->大程式 GitHub, Bitbucket……作品集 接下來就是你們的時間囉XD 還有更複雜的操作 規劃適合的工作流
44 參考連結 ◎分散式工作流程 ◎Denny Huang ◎Bitbucket tutorial ◎連猴子都能懂得git入門指南 ◎Git immersion
45 Q&A
46 feedback