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
Learn Git
Search
Lin Zhang
May 06, 2013
Programming
0
130
Learn Git
Git introduction, commands, tips and Github.
Lin Zhang
May 06, 2013
Tweet
Share
Other Decks in Programming
See All in Programming
CSC307 Lecture 03
javiergs
PRO
1
490
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
6
1.9k
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
610
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
250
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
240
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
250
Fluid Templating in TYPO3 14
s2b
0
130
高速開発のためのコード整理術
sutetotanuki
1
390
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
180
Fragmented Architectures
denyspoltorak
0
150
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
8k
Navigating Team Friction
lara
192
16k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
670
The Curse of the Amulet
leimatthew05
1
8.2k
For a Future-Friendly Web
brad_frost
182
10k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
110
Docker and Python
trallard
47
3.7k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
290
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
110
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
100
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Transcript
Learn Git Lin Zhang - @marshluca 2013.5.4 13年5月4⽇日星期六
Agenda • Git Introduction • Git Commands • Git Tips
• Github 13年5月4⽇日星期六
Git Introduction • Distributed Version Control System • Linux Torvalds
created for Linux Kernel • 2005.4 released 13年5月4⽇日星期六
谁在⽤用Git 13年5月4⽇日星期六
My Version Control System • 2009 Subversion (co, ci, up)
• 2011 Git (repo on private server) • 2012 Github, Bitbucket (pull request) 13年5月4⽇日星期六
Subversion-Style Workflow 13年5月4⽇日星期六
Integration Manager Workflow 13年5月4⽇日星期六
13年5月4⽇日星期六
脱离SVN苦海 git svn clone -‐-‐stdlayout -‐-‐no-‐metadata \ -‐A users.txt
svn://hostname/path dest_dir-‐tmp http://stackoverflow.com/questions/79165/how-‐to-‐migrate-‐svn-‐ with-‐history-‐to-‐a-‐new-‐git-‐repository 13年5月4⽇日星期六
完全离线开发 13年5月4⽇日星期六
四种状态 13年5月4⽇日星期六
Git Commands 13年5月4⽇日星期六
初试⽜牛⼑刀 • mkdir -p repo && cd repo • git
init • touch README • git add README • git status • git commit -m ‘First Commit’ 13年5月4⽇日星期六
分⽀支合并 • git branch my-branch • git checkout my-branch •
git rebase develop • git merge my-branch 13年5月4⽇日星期六
远程交互 • git remote add upstream <git-repo-url> • git fetch
upstream • git pull upstream master • git push origin master 13年5月4⽇日星期六
还有很多... • git mv file • git rm file •
git log • git diff • git reset --hard HEAD • git tag -a v1.0 -m ‘tagging v1.0’ 13年5月4⽇日星期六
Git Tips 13年5月4⽇日星期六
#Tip1 Make Alias In Config 13年5月4⽇日星期六
#Tip2 Manage Remote Branches • git checkout --track origin/branch •
git branch -D local-branch • git push origin local-branch:remote-branch • git push origin :remote-branch 13年5月4⽇日星期六
#Tip3 Amend on commit • with reset • git reset
HEAD~ • update • git commit -am ‘some message’ • with amend • update • git commit -a --amend 13年5月4⽇日星期六
#Tip4 Stash Local Changes Before Merge/Patch • git stash •
git stash save ‘your message’ • git stash list • git stash pop • git stash apply stash@{0} • git stash drop stash@{0} • git stash clear 13年5月4⽇日星期六
#Tip5 pick existed commits git cherry-pick master~3 git cherry-pick master~4
master~2 13年5月4⽇日星期六
#Tip6 Push之前可以做的事 • git reset HEAD~2 • --soft • --hard
• git amend -a --amend • git rebase -i HEAD~3 13年5月4⽇日星期六
#Tip7 Merge with --no-ff fast-forward no fast-forward 13年5月4⽇日星期六
#Tip8 pull with rebase 13年5月4⽇日星期六
D---E master / A---B---C---F origin/master D--------E / \ A---B---C---F----G master,
origin/master git pull origin master A---B---C---F---D'---E' master, origin/master git pull --rebase origin master 13年5月4⽇日星期六
#Tip9 Recover your changes • git revert HEAD~ • git
revert HEAD~1 --no-edit --mainline 2 13年5月4⽇日星期六
#Tip10 冲突了怎么办? • 导致冲突的元凶 merge, patch • 导致冲突的直接命令 • merge,
pull, rebase, cherry-pick 13年5月4⽇日星期六
冲突类型及解决 • 逻辑冲突 • auto merged/patched • ⽂文件树冲突 • git
mergetool • 内容冲突 • merge/patch • rebase 13年5月4⽇日星期六
什么是⼈人⾁肉合并 >.< • 干掉7个>,< • 卷⼟土重来 • git reset --hard
HEAD • git merge --abort • git rebase --abort 13年5月4⽇日星期六
如何避免⼤大⾯面积冲突 13年5月4⽇日星期六
Commit Guidelines • Commit related changes • Commit small and
often • Dont commit half-done work • Test code before commit • Write good commit message 13年5月4⽇日星期六
Branch Guidelines • Keep master branch always deployable • Develop
features on new local branches • Stash you local changes when switch to another branch 13年5月4⽇日星期六
Merge Guidelines • Merge more often and earyly • Merge
with rebase • Test code before merge 13年5月4⽇日星期六
Rebase Guidelines • Never rebase your master branch • Never
rebase a published branch • Rebase your feature branches 13年5月4⽇日星期六
Social Coding on Github 13年5月4⽇日星期六
Follow && Watch 13年5月4⽇日星期六
Repositories 13年5月4⽇日星期六
Fork, Pull Request 13年5月4⽇日星期六
Github Issues Talk is cheap, show me the code! 13年5月4⽇日星期六
Github Pages 13年5月4⽇日星期六
Recommend tools 13年5月4⽇日星期六
Gitx 13年5月4⽇日星期六
tig 13年5月4⽇日星期六
git flow 13年5月4⽇日星期六
feature, release, hotfix • git flow init -d • git
flow feature start feature-x • git flow feature rebase • git flow feature finish feature-x 13年5月4⽇日星期六
References • http://progit.org • http://book.git-scm.com • http://gitref.org • http://thkoch2001.github.io/whygitisbetter/ •
http://ihower.tw/blog/archives/category/git 13年5月4⽇日星期六
Thanks ! Q/A 13年5月4⽇日星期六