狠狠撸

狠狠撸Share a Scribd company logo
连哈秋都懂的骋颈迟教学
2015/10/04@HTCG
hydai<hydai@gapp.nthu.edu.tw>
投影?片授權
? CC by-nc 3.0
? 你可以分享、改作
? 不能拿去做商業運?用喔!
? creativecommons.org/licenses/by-nc/3.0/tw/
哈秋是誰?
我實習公司的貓貓
好萌好可愛
喜歡?用側邊磨蹭
好萌好可愛
會指揮貓奴跟他玩或進貢??食物
好萌好可愛
hachu.cat
潛規則
DEMO 失敗要記得?鼓掌(X)
?口誤都是事先 set 好的(X)
廢話太多可以?用眼神打斷我(X)
歡迎多問問題(O)
先来做?一下调查
?用過 Git 的舉?手
聽過 Git 的舉?手
你有过这种经验吗?
?老師說:
基礎功能完成以後,
可以繼續做加分功能
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
來源:
寫程式?那些?老師沒教的事
2012/07/15 @StudyArea-Taichung
畢?玉泉 (?小畢/CrBoy) <crboy@crboy.net>
做 Project 的時候
有時候就不是?一個檔案的事了
最初的资料夹
沒想到有 Bug 只好標?示?一下
解掉 Bug 了,複製?一份新的?比較安全
F**K ?又有 Bug 了,再来?一份
不?行,我忘记哪个是最新的了,加上版本号好了
版本越来越多
終於 Final 版出來了
有 Bug 我再繼續修
Final 後還有 贵颈苍补濒…
有時候有更多的 贵颈苍补濒…
做 Project 的時候
有時候也不是?一個?人的事了吧(?)
多?人协作的时候怎麼办?
A ?方案:
我們各改各的,最後再來融合
功能融合不起来?!!!
功能融合不起来?!!!
G_G
B ?方案:
別怕,只要?用 Dropbox 同步
我們就可以同時改?一份 Code
你他O的把我的 Code 蓋掉啦?!
你他O的把我的 Code 蓋掉啦?!
G_G
所以我们想解决什麼?
??目標
隨時可以回到純真年代,在 Code 被修改之前
協作時, Code 不會意外的被蓋掉
容易找戰犯 我是說可以查詢歷史紀錄
可以控管很多很多種版本(交作業?用、借?人抄?用)
版本控制系统因?而诞?生
Version Control System
Repository -> 數據庫,紀錄歷史的地?方
Local -> 本地端,通常個?人使?用的地?方
Remote -> 遠端,通常是?一個共?用的伺服器
在介紹前,先看看專有名詞
VCS ?大體可以分兩種
Centralised VCS
Repository
Server (remote)
Copy
User#1
Copy
User#2
commit
update commit
update
Distributed VCS
Repository
Server (remote)
Copy
User#1
Copy
User#2
Repository Repository
Push
Pull
Push
Pull
Update Commit Update Commit
Local Local
今天的主?角 - Git
Distributed VCS
Repository
Server (remote)
Copy
User#1
Copy
User#2
Repository Repository
Push
Pull
Push
Pull
Update Commit Update Commit
Local Local
?大概像是?一位歷史学家
git <command> [arguments]
git <command> --help 看到指令的提?示
?一招?走天下
切換到你想要做版本控制的地?方
打上 git init
這位歷史學家就會進駐囉!
建?立 Repository
當已經有歷史存在時,可以把過去的歷史繼承下來
git clone <url>
就可以把別?人的 repo 複製?一份下來囉
已經存在的 Repository
很安全的基礎指令
查看??目前狀態: git status
查看歷史紀錄: git log
查看檔案差異: git diff
查看特定紀錄: git show
Git 寫歷史的流程
來源:
http://git-scm.com/about/staging-area
當前的?工作環境
數據庫
準備進?入數據庫的階段
將修改放?入 Stage 階段
git add <file/folder>
git add -A #?一次加全部,但是要?小?心
將修改移出 Stage 階段
git rm --cached <file>
git rm -r --cached <folder>
將修改放?入 repository
git commit -m "message"
適合 commit message 很短的時候
git commit -a
將打開互動式編輯器,寫上 commit message
存檔離開以後就完成啦!
commit message 錯誤範例
commit message 建議習慣
第?一?行是主題,盡量在五?十個字元內寫完
空?一?行
第三?行是細節,解釋更多資訊
盡量?一?行不要超過七?十?二的字元
Git 寫歷史的狀態
來源:
https://ihower.tw/git/basic.html
不想被加進去的檔案
寫進去 .gitignore 的檔案中
通常我們不會把以下檔案放進去 repo 中
暫存檔案
個?人設定檔案
編譯產?生的檔案
很棒的 gitignore 整理:https://github.com/github/gitignore
今天的配?角 - GitHub
GitHub
章?魚貓
可以存放 Git 的 repo
強?大的 issue tracking system
?一?大堆開源軟體
學?生專案快去?用呀~~~
education.github.com/pack
在 GitHub 上建?立 repo
git remote <sub-command>
git remote add <remote-name> <url>
設定 remote
git push <remote-name> <branch-name>
推上 remote 吧!
Push 的時候要注意
hint: Updates were rejected because the
tip of your current branch is behind
Push 失敗的訊息
這時候就?用等?一下要講的 Pull
絕對不要這麼做
git push --force
连哈秋都懂的骋颈迟教学
git pull <remote-name> <branch-name>
pull 其實是 fetch + merge
所以會多出?一個點表?示與 remote 融合
git pull --rebase 則是會?用 rebase 取代 merge
git log 出來的圖會?比較好看
從 remote 把最新的版本拉下來吧
通常 pull 有機會遇到這個情況
你跟朋友同時改了同個檔案
然後就 conflict 了
如何解 conflict ?
你可能會看到這個樣?子:
<<<<<<<<<<<<< HEAD
XXXXXXXX
=============
OOOOOOOO
>>>>>>>>>>>>> 8gh893sg897wgs897h
如何解 conflict ?
想辦法合併以後就會變成這個樣?子:
XXOOXXXX
OOOXXXOO
存檔後就可以繼續 commit 了!
想要修改已經 commit 的東?西?
git rebase -i HEAD~X
從某個 commit 開始調整
有請歷史學家~
最后?用来伤感情的指令
git blame <file>
可以看到每?一?行是誰寫的,想賴都賴不掉
如何找戰犯
参考资料
初學?入?門專?用
? 互動式學 Git
? try.github.io
? 詳細教學?文+實例操作
? backlogtool.com/git-guide/tw/
? 三?十天學 Git 系列
? github.com/doggy8088/Learn-Git-in-30-days
参考资料
? 寫程式?那些?老師沒教的事
? blog.crboy.net/2012/04/release-slides-of-
code-smart.html
? ihower Git 教材
? ihower.tw/git/basic.html
? git-scm
? git-scm.com/about/staging-area
有趣的?小東?西
? git-fire!!!
? github.com/qw3rtman/git-fire

More Related Content

What's hot (20)

Git ???? ?? ???
Git ???? ?? ???Git ???? ?? ???
Git ???? ?? ???
chandler0201
?
Git basic
Git basicGit basic
Git basic
Emran Ul Hadi
?
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
?
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
Sandeep Chawla
?
Git ??? GitHub(Git????? ??) / Getting started with git+github
Git ??? GitHub(Git????? ??) / Getting started with git+githubGit ??? GitHub(Git????? ??) / Getting started with git+github
Git ??? GitHub(Git????? ??) / Getting started with git+github
Junyoung Lee
?
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos
?
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
Sébastien Saunier
?
Git and Github
Git and GithubGit and Github
Git and Github
Wen-Tien Chang
?
Git and git flow
Git and git flowGit and git flow
Git and git flow
Fran García
?
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
Lemi Orhan Ergin
?
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
?
Jenkins x Kubernetesが簡単だと思ったら大変だった話
Jenkins x Kubernetesが簡単だと思ったら大変だった話Jenkins x Kubernetesが簡単だと思ったら大変だった話
Jenkins x Kubernetesが簡単だと思ったら大変だった話
Masaki Yamamoto
?
Github basics
Github basicsGithub basics
Github basics
Radoslav Georgiev
?
Git
GitGit
Git
Mayank Patel
?
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
"FENG "GEORGE"" YU
?
Version Control with Git & GitHub
Version Control with Git & GitHubVersion Control with Git & GitHub
Version Control with Git & GitHub
Piet Cordemans
?
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
?
WebRTCの技術解説 公開版
WebRTCの技術解説 公開版WebRTCの技術解説 公開版
WebRTCの技術解説 公開版
Contest Ntt-west
?
すごい叠翱厂贬たのしく学ぼう
すごい叠翱厂贬たのしく学ぼうすごい叠翱厂贬たのしく学ぼう
すごい叠翱厂贬たのしく学ぼう
i_yudai
?

Viewers also liked (6)

写程式?那些老师没教的事
写程式?那些老师没教的事写程式?那些老师没教的事
写程式?那些老师没教的事
均民 戴
?
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
均民 戴
?
Git 入門與實作
Git 入門與實作Git 入門與實作
Git 入門與實作
奕浦 郭
?
Jira 教學
Jira 教學Jira 教學
Jira 教學
Doremi Lin
?
git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學
Doremi Lin
?
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
littlebtc
?
写程式?那些老师没教的事
写程式?那些老师没教的事写程式?那些老师没教的事
写程式?那些老师没教的事
均民 戴
?
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
均民 戴
?
Git 入門與實作
Git 入門與實作Git 入門與實作
Git 入門與實作
奕浦 郭
?
git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學
Doremi Lin
?
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
littlebtc
?

Similar to 连哈秋都懂的骋颈迟教学 (20)

大家應該都要會的工具 Git 從放棄到會用1-基礎篇
大家應該都要會的工具 Git   從放棄到會用1-基礎篇大家應該都要會的工具 Git   從放棄到會用1-基礎篇
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
Alan Tsai
?
大家應該都要會的工具 Git 從放棄到會用2-分支篇
大家應該都要會的工具 Git   從放棄到會用2-分支篇大家應該都要會的工具 Git   從放棄到會用2-分支篇
大家應該都要會的工具 Git 從放棄到會用2-分支篇
Alan Tsai
?
電子內容管理 使用Git 與 github 1
電子內容管理   使用Git 與 github 1電子內容管理   使用Git 與 github 1
電子內容管理 使用Git 與 github 1
Alan Tsai
?
Git 入门实战
Git 入门实战Git 入门实战
Git 入门实战
icy leaf
?
Git and Github basic with SourceTree
Git and Github basic with SourceTreeGit and Github basic with SourceTree
Git and Github basic with SourceTree
Chu-Siang Lai
?
COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報
Bachue Zhou
?
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
Nelson Tai
?
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹
PingLun Liao
?
Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final
Paul Chao
?
Git
GitGit
Git
Min Micro
?
工程師必備第一工具 - Git
工程師必備第一工具 - Git工程師必備第一工具 - Git
工程師必備第一工具 - Git
Alan Tsai
?
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀
Wen-Tien Chang
?
Git and git hub
Git and git hubGit and git hub
Git and git hub
唯 李
?
骋颈迟入门介绍
骋颈迟入门介绍骋颈迟入门介绍
骋颈迟入门介绍
mudream4869
?
骋颈迟流派与工作流程.辫辫迟虫
骋颈迟流派与工作流程.辫辫迟虫骋颈迟流派与工作流程.辫辫迟虫
骋颈迟流派与工作流程.辫辫迟虫
健誠 呂
?
Learning to Use Git | WeiYuan
Learning to Use Git | WeiYuanLearning to Use Git | WeiYuan
Learning to Use Git | WeiYuan
Wei-Yuan Chang
?
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
Drake Huang
?
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Bo-Yi Wu
?
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
維佋 唐
?
First meetingwithgit
First meetingwithgitFirst meetingwithgit
First meetingwithgit
Rhythm Sun
?
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
大家應該都要會的工具 Git   從放棄到會用1-基礎篇大家應該都要會的工具 Git   從放棄到會用1-基礎篇
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
Alan Tsai
?
大家應該都要會的工具 Git 從放棄到會用2-分支篇
大家應該都要會的工具 Git   從放棄到會用2-分支篇大家應該都要會的工具 Git   從放棄到會用2-分支篇
大家應該都要會的工具 Git 從放棄到會用2-分支篇
Alan Tsai
?
電子內容管理 使用Git 與 github 1
電子內容管理   使用Git 與 github 1電子內容管理   使用Git 與 github 1
電子內容管理 使用Git 與 github 1
Alan Tsai
?
Git 入门实战
Git 入门实战Git 入门实战
Git 入门实战
icy leaf
?
Git and Github basic with SourceTree
Git and Github basic with SourceTreeGit and Github basic with SourceTree
Git and Github basic with SourceTree
Chu-Siang Lai
?
COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報
Bachue Zhou
?
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
Nelson Tai
?
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹
PingLun Liao
?
Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final
Paul Chao
?
工程師必備第一工具 - Git
工程師必備第一工具 - Git工程師必備第一工具 - Git
工程師必備第一工具 - Git
Alan Tsai
?
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀
Wen-Tien Chang
?
Git and git hub
Git and git hubGit and git hub
Git and git hub
唯 李
?
骋颈迟入门介绍
骋颈迟入门介绍骋颈迟入门介绍
骋颈迟入门介绍
mudream4869
?
骋颈迟流派与工作流程.辫辫迟虫
骋颈迟流派与工作流程.辫辫迟虫骋颈迟流派与工作流程.辫辫迟虫
骋颈迟流派与工作流程.辫辫迟虫
健誠 呂
?
Learning to Use Git | WeiYuan
Learning to Use Git | WeiYuanLearning to Use Git | WeiYuan
Learning to Use Git | WeiYuan
Wei-Yuan Chang
?
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Bo-Yi Wu
?
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
維佋 唐
?
First meetingwithgit
First meetingwithgitFirst meetingwithgit
First meetingwithgit
Rhythm Sun
?

More from hydai (6)

Introduction to Ewasm - crosslink taipei 2019
Introduction to Ewasm - crosslink taipei 2019Introduction to Ewasm - crosslink taipei 2019
Introduction to Ewasm - crosslink taipei 2019
hydai
?
Introduction to ewasm
Introduction to ewasmIntroduction to ewasm
Introduction to ewasm
hydai
?
Lity - 讓你更安全的 Smart Contract Language
Lity - 讓你更安全的 Smart Contract LanguageLity - 讓你更安全的 Smart Contract Language
Lity - 讓你更安全的 Smart Contract Language
hydai
?
COSCUP2016 - LLVM框架、由淺入淺
COSCUP2016 - LLVM框架、由淺入淺COSCUP2016 - LLVM框架、由淺入淺
COSCUP2016 - LLVM框架、由淺入淺
hydai
?
Vim 由淺入淺
Vim 由淺入淺Vim 由淺入淺
Vim 由淺入淺
hydai
?
Slack&typora
Slack&typoraSlack&typora
Slack&typora
hydai
?
Introduction to Ewasm - crosslink taipei 2019
Introduction to Ewasm - crosslink taipei 2019Introduction to Ewasm - crosslink taipei 2019
Introduction to Ewasm - crosslink taipei 2019
hydai
?
Introduction to ewasm
Introduction to ewasmIntroduction to ewasm
Introduction to ewasm
hydai
?
Lity - 讓你更安全的 Smart Contract Language
Lity - 讓你更安全的 Smart Contract LanguageLity - 讓你更安全的 Smart Contract Language
Lity - 讓你更安全的 Smart Contract Language
hydai
?
COSCUP2016 - LLVM框架、由淺入淺
COSCUP2016 - LLVM框架、由淺入淺COSCUP2016 - LLVM框架、由淺入淺
COSCUP2016 - LLVM框架、由淺入淺
hydai
?
Vim 由淺入淺
Vim 由淺入淺Vim 由淺入淺
Vim 由淺入淺
hydai
?
Slack&typora
Slack&typoraSlack&typora
Slack&typora
hydai
?

连哈秋都懂的骋颈迟教学