SlideShare a Scribd company logo
TONY DENG
https://tonydeng.github.io
https://twitter.com/wolfdeng
为什么要版本控制?
图解Git
图解Git
图解Git
图解Git
图解Git
……
……
……
……
图解Git
图解Git
图解Git
图解Git
......
图解Git
......
图解Git
......
......
......
......
......
......
图解Git
......
......
......
图解Git
……
图解Git
图解Git
......
图解Git
图解Git
图解Git
图解Git
图解Git
......
......
……
图解Git
图解Git
图解Git
图解Git
图解Git
( )
( )
FFFFFF
FFFFFF
FFFFFF
FFFUU
UUUU
UUUU
UUUU
UUU-
( )
FFFFFF
FFFFFF
FFFFFF
FFFUU
UUUU
UUUU
UUUU
UUU-
……
……
11:00
10:00
9:00
8:00
11:00
10:00
9:00
8:00
•
•
•
•
•
• Linus Torvalds Linux
•
•
•
•
•
•
Terminal
CLI
• —
•
•
•
GIT
https://git-scm.com/
Mac
brew install git
Ubuntu/Debian
apt-get install git
Fedora/CentOS
yum install git-core
Windows
google/baidu
GIT
Setup
git config —global user.name “your name”
email
git config —global user.email “your email”
Basic
• git
git init
( )
Coding
STAGE
•
•
• Stage
git add file1 file2
COMMIT
•
•
• (commit message)
•
git commit -m ‘message’
图解Git
Stage
a.txt
Stage
a.txt
ADD
a.txt
git add a.txt
COMMIT
a.txt
git commit -m ‘update a’
Stage
git
• commit
git diff
• commit HASH
commit message
git log
• commit
git reset —hard git checkout .
•
git checkout a.txt
• git checkout commit HASH
• commit
[c164575]
[257ffc9]
[81a6cf1]
git checkout 257ffc9
• git checkout (branch name)
• master
[c164575]
[257ffc9]
[81a6cf1]
git checkout master
<master>
•
• HEAD
[c164575]
[257ffc9]
[81a6cf1]
git checkout HEAD^
git checkout HEAD~
git checkout HEAD~1
<HEAD>
<HEAD>
commit
•
• HEAD
[c164575]
[257ffc9]
[81a6cf1]
git checkout HEAD^
<HEAD>
<HEAD>
<HEAD>
git checkout HEAD^
•
• HEAD
[c164575]
[257ffc9]
[81a6cf1]
git checkout HEAD^^
<HEAD>
<HEAD>
<HEAD>
git checkout HEAD~2
commit
COMMIT
• commit
• <master>
commit commit
<master>
<master>
git reset —hard HEAD^
COMMIT
• commit
• checkout
<master>
<master>
git reset —hard HEAD^^[c164575]
[257ffc9]
[81a6cf1]
git reset —hard 81a6cf1
git reset —hard master~2
<HEAD>
git branch
<master>
<master> <develop>
git branch develop
git checkout develop
git checkout -b develop
<master>
<develop>
git add —all
git commit -m ‘…’
……
Stage
commit!
<master>
<develop>
git checkout master
<master>
<develop>
<master>
<develop>
git checkout master
git merge develop
master
develop
图解Git
图解Git
图解Git
git add
git commit …
git remote
• git repository(Repo)
git init repository
• git ——>
•
• gitlab ——>
• git remote repository
git remote add origin git@github.com:tonydeng/gitignore.git
git remote add origin https://github.com/tonydeng/gitignore.git
origin
origin
<master>
<master>
git push origin master
origin
<develop>
<develop>
git push origin develop
origin
<master>
<master>
git pull origin master
origin
<master>
<master>
git clone git@github.com:tonydeng/gitignore.git
origin
git clone https://github.com/tonydeng/gitignore.git
图解Git
Remote Repo
A
B
git clone …
git clone …
Remote Repo
A
B
B commit
Remote Repo
A
B
A commit
Remote Repo
A
B
Remote Repo
A
B
A push
Remote Repo
A
B
B push…
Remote Repo
A
B
B pull…
fetch
pull = fetch & merge
Remote Repo
A
B
B pull…
fetch
merge
pull = fetch & merge
B push
B push
PULL = FETCH & MERGE !
• pull merge
• merge merge
git stash
• branch .......
commit
• branch .......
commit
git stash
• branch .......
commit
git stash
• branch .......
commit
git stash
git stash save ‘…’
• stash
git stash list stash
git stash pop git stash pop
git stash apply git stash apply
git stash drop git stash drop
( ) stash
pop stash
stash
Git Flow
http://nvie.com/posts/a-successful-git-branching-model/
Branch怎 用?
git flow
• master : production
• develop :
master checkout
图解Git
• feature branches
• bugs
• develop
• merge develop
• develop
图解Git
• release branches
• release bugs
• develop
• merge master develop
• hotfix branches
• release
• master
• merge master develop
图解Git
Q & A

More Related Content

TXT
De inferno pistol round (t)
PDF
PDF
Opensource 是人生的好朋友 2016-07-21
 
PDF
FPGA MiSTer (July 2019)
PDF
METEOR on ARM | Meteor Meetup Talk
PDF
dockerはじめました。 GDG京都 2014年忘れ勉強会 LT
PDF
PDF
De inferno pistol round (t)
Opensource 是人生的好朋友 2016-07-21
 
FPGA MiSTer (July 2019)
METEOR on ARM | Meteor Meetup Talk
dockerはじめました。 GDG京都 2014年忘れ勉強会 LT

Viewers also liked (9)

PDF
一次Code review引发的思考
PDF
Shoutv 冯晓东
PDF
JavaScript Patterns
PPT
设计模式 精选
PDF
一次Http请求过程分析
PDF
Scrum敏捷开发模型
PDF
漫谈职业规划
PDF
一次项目的探险旅程
PDF
My sql迁移总结
一次Code review引发的思考
Shoutv 冯晓东
JavaScript Patterns
设计模式 精选
一次Http请求过程分析
Scrum敏捷开发模型
漫谈职业规划
一次项目的探险旅程
My sql迁移总结
Ad

Similar to 图解Git (20)

KEY
Git isthenewsexy
KEY
The Git - (#1/2)
PDF
Working with Git
PDF
Distributed Developer Workflows using Git
PDF
Presentacion git
PDF
Starting with Git & GitHub
KEY
Introduction To Git
PDF
Introduction to Git, DrupalCamp LA 2015
PPTX
Introduction to GitHub, Open Source and Tech Article
PPTX
Github basics
PDF
Fall18 Git presentation
KEY
Onsg10 Intro Termtter
PDF
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
PDF
Git training
KEY
Gitting the Most From Git
PDF
Now i git it!!!
PDF
Collaborative development with git
PDF
Loading...git
Git isthenewsexy
The Git - (#1/2)
Working with Git
Distributed Developer Workflows using Git
Presentacion git
Starting with Git & GitHub
Introduction To Git
Introduction to Git, DrupalCamp LA 2015
Introduction to GitHub, Open Source and Tech Article
Github basics
Fall18 Git presentation
Onsg10 Intro Termtter
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
Git training
Gitting the Most From Git
Now i git it!!!
Collaborative development with git
Loading...git
Ad

More from Tony Deng (20)

PDF
一页纸项目管理
PDF
Docker at the gate
PDF
《我们如何工作》—质量保障
PDF
《我们如何工作》- 产品经理和工程师如何有效沟通
PDF
我们为何工作--找到正确的工作方式
PPTX
SDN介绍
PDF
技术债务的形成
KEY
我们不了解的计算机世界(二)
PPTX
HBase
KEY
我们不了解的计算机世界(一)--Unix目录结构的来历
PPTX
实时任务调度
KEY
节约内存:Instagram的redis实践
KEY
晁盖与宋江的“兄弟情谊”
PPTX
非常靠谱 Html 5
PPTX
施耐庵究竟怎样写武松
PPTX
我们的岛,又有多大
PPTX
数据挖掘九律
PPTX
核辐射乱谈
PPTX
Bash的快捷键
PPTX
西游记里那些可爱的小妖们
一页纸项目管理
Docker at the gate
《我们如何工作》—质量保障
《我们如何工作》- 产品经理和工程师如何有效沟通
我们为何工作--找到正确的工作方式
SDN介绍
技术债务的形成
我们不了解的计算机世界(二)
HBase
我们不了解的计算机世界(一)--Unix目录结构的来历
实时任务调度
节约内存:Instagram的redis实践
晁盖与宋江的“兄弟情谊”
非常靠谱 Html 5
施耐庵究竟怎样写武松
我们的岛,又有多大
数据挖掘九律
核辐射乱谈
Bash的快捷键
西游记里那些可爱的小妖们

Recently uploaded (20)

PPTX
Current and future trends in Computer Vision.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
Construction Project Organization Group 2.pptx
PDF
composite construction of structures.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Artificial Intelligence
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Current and future trends in Computer Vision.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
R24 SURVEYING LAB MANUAL for civil enggi
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Construction Project Organization Group 2.pptx
composite construction of structures.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Artificial Intelligence
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Safety Seminar civil to be ensured for safe working.
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Mechanical Engineering MATERIALS Selection
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
III.4.1.2_The_Space_Environment.p pdffdf
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems

图解Git