Git Real

Gong Haibing
Gong HaibingBackend Developer/Leader/DevOps at Guangzhou Sponia Software Co., Ltd
Git Real
@dylanninin
• What is Git
• Internals
• Play with Git
• Workflow
• Q&A
What is Git
A long time ago
SCM Timeline
Git != Subversion + Magic!
Git != Subversion + Magic!
- Git is a stupid content tracker.

- It is simply used as an SCM, not really designed as one. 

- In many ways you can just see git as a file system
“In many ways you can just see git as a file system — it’s content- addressable,
and it has a notion of versioning, but I really really designed it coming at the
problem from the viewpoint of a file system person (hey, kernels is what I do),
and I actually have absolutely zero interest in creating a traditional SCM
system.”
– Linus (http://marc.info/?l=linux-kernel&m=111314792424707)
Git Design
• Non-Linear Development
• Distributed Development
• Efficiency
Git Internals
Internals - The Model
Internals - Git Objects
• Git objects are the actual data of Git, the main thing that the repository is made up of
• Each object is compressed (with Zlib) and referenced by the SHA-1 value of its contents
plus a small header:
• full SHA-1: dae86e1950b1277e545cee180551750029cfe735
• partial SHA-1: dae86e 

• There are four main object types in Git:
• Blob
• Tree
• Commit
• Tag
Internals - Working Directory
The Blob
The Blob
The Tree
The Tree
The Commit
The Commit
The Tag
Internals - Example
• current repository with one commit
• and its’ logical structure
Internals - Example
• modify lib/base/base_include.rb
• add a release tag v0.1
Internals - Example
• modify init.rb
Internals - Example
• history view
Internals - Example
• git checkout v0.1
Internals - Branching and Merging
• Branches resident in .git/ refs/heads
• Creating a branch is nothing more than just writing 40 characters to a file
Internals - Remotes
• origin/master
• local master
Internals - Remotes
• origin/master
• origin/idea
• local master
Internals - Merge
• local master
• tag T1
• feature branch experiment
Internals - Merge
• merge experiment into master
• delete experiment branch
Internals - Rebase
• commits, pull and merge
• history becomes worse and confusing
Internals - Rebase
• orphans Commit 1
• applies the changes between Commit 0 and Commit 1 to the files in Remote Commit 1
• creating a new Commit 2
Internals - Rebase
• as you’ll remember, you and Jen both commit again
Internals - Rebase
• rebase next two commits
Internals - Rebase
• rebase next two commits
Internals - Rebase
• rebase with linear history
• merge sucks a lot
Play with Git
Play with Git - config
• git config —global user.name “Dylan”
• git config —global user.email “dylanninin@gmail.com
Or
[user]
name = Dylan
email = dylanninin@gmail.com
[core]
excludesfile = ~/.gitignore
editor = vim
[alias]
co = checkout
[log]
date = relative
More such example
• https://gist.github.com/pksunkara/988716
• ~/.gitconfig
Play with Git - .git directory
http://www.gitguys.com/topics/the-git-directory/
Play with Git - model
• repository/remote/workspace
• index area
Play with Git - work hard
http://www.gitguys.com/topics/the-git-directory/
Play with Git - help
• git help <command>|<concept>
• git help -a
• git help -g
The common Git guides are:
attributes Defining attributes per path
everyday Everyday Git With 20 Commands Or So
glossary A Git glossary
ignore Specifies intentionally untracked files to ignore
modules Defining submodule properties
revisions Specifying revisions and ranges for Git
tutorial A tutorial introduction to Git (for version 1.5.1 or newer)
workflows An overview of recommended workflows with Git
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
Git Real
Workflow
Git-flow
Github Flow
create a

branch
add 

commits
open a

pull
request
discuss
&

review
deploy
merge

into

master
In case of fire
Q & A
Reference
• Git: https://en.wikipedia.org/wiki/Git_(software)
• Linus on Git: https://www.youtube.com/watch?v=4XpnKHJAok8
• Pro Git: http://git-scm.com/book
• Git Internals: http://git-scm.com/book/en/v1/Git-Internals
• Peepcode Git Internals: https://github.com/pluralsight/git-internals-pdf
• SHA-1: https://en.wikipedia.org/wiki/SHA-1
• Facebook’s git repo is 54GB: https://news.ycombinator.com/item?id=7648237
• Git Branching model: http://nvie.com/posts/a-successful-git-branching-model/
• Github Flow: 

- http://scottchacon.com/2011/08/31/github-flow.html

- https://guides.github.com/introduction/flow/
1 of 48

More Related Content

What's hot

GittalkGittalk
Gittalkprtinsley
787 views76 slides
git and githubgit and github
git and githubDarren Oakley
13.1K views68 slides
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
11.7K views42 slides

What's hot(20)

GittalkGittalk
Gittalk
prtinsley787 views
Git and GitHubGit and GitHub
Git and GitHub
Md. Ahsan Habib Nayan1.2K views
git and githubgit and github
git and github
Darren Oakley13.1K views
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
SheilaJimenezMorejon858 views
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp11.7K views
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
Paulo Henrique Nonaka1.7K views
GithubGithub
Github
JaneAlamAdnan458 views
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee1.3K views
Learn Git BasicsLearn Git Basics
Learn Git Basics
Prakash Dantuluri736 views
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
GoogleDeveloperStude4661 views
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
Ariejan de Vroom1.6K views
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla1.2K views
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon Melbourne
Paal Ringstad264 views
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
Ariejan de Vroom1.6K views
Git IntroductionGit Introduction
Git Introduction
Gareth Hall1.3K views
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Matthew McCullough695 views
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam758 views
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup67.2K views
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
Katie Sylor-Miller2.9K views

Similar to Git Real(20)

11 git version control11 git version control
11 git version control
Wasim Alatrash45 views
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the stars
Strannik_20131.1K views
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith3.5K views
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Roland Emmanuel Salunga446 views
Introduction to gitIntroduction to git
Introduction to git
Nguyen Van Hung164 views
Intro to Git & GitHubIntro to Git & GitHub
Intro to Git & GitHub
GoogleDevelopersStud254 views
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
Tim Osborn2.3K views
Mini git tutorialMini git tutorial
Mini git tutorial
Cristian Lucchesi1.5K views
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar722 views
GIT-FirstPart.pptGIT-FirstPart.ppt
GIT-FirstPart.ppt
ssusered2ec214 views
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
Salvatore Cordiano626 views
Mastering gitMastering git
Mastering git
Christopher Gomez380 views
Git hub for designersGit hub for designers
Git hub for designers
FITC1.1K views
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
tnscharishma131 views

More from Gong Haibing

Nginx EssentialNginx Essential
Nginx EssentialGong Haibing
924 views53 slides
How to Code ReviewHow to Code Review
How to Code ReviewGong Haibing
439 views44 slides
Search EngineSearch Engine
Search EngineGong Haibing
288 views57 slides

More from Gong Haibing(9)

Ansible IntroductionAnsible Introduction
Ansible Introduction
Gong Haibing219 views
Nginx EssentialNginx Essential
Nginx Essential
Gong Haibing924 views
How to Code ReviewHow to Code Review
How to Code Review
Gong Haibing439 views
A Byte of Software DeploymentA Byte of Software Deployment
A Byte of Software Deployment
Gong Haibing390 views
Sponia with QingCloudSponia with QingCloud
Sponia with QingCloud
Gong Haibing297 views
Search EngineSearch Engine
Search Engine
Gong Haibing288 views
Jenkins-CIJenkins-CI
Jenkins-CI
Gong Haibing750 views
Linux FundamentalLinux Fundamental
Linux Fundamental
Gong Haibing853 views
Database FundamentalDatabase Fundamental
Database Fundamental
Gong Haibing2.1K views

Recently uploaded(20)

Green Leaf Consulting: Capabilities DeckGreen Leaf Consulting: Capabilities Deck
Green Leaf Consulting: Capabilities Deck
GreenLeafConsulting170 views
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet48 views
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)
CSUC - Consorci de Serveis Universitaris de Catalunya51 views

Git Real

  • 2. • What is Git • Internals • Play with Git • Workflow • Q&A
  • 6. Git != Subversion + Magic!
  • 7. Git != Subversion + Magic! - Git is a stupid content tracker.
 - It is simply used as an SCM, not really designed as one. 
 - In many ways you can just see git as a file system “In many ways you can just see git as a file system — it’s content- addressable, and it has a notion of versioning, but I really really designed it coming at the problem from the viewpoint of a file system person (hey, kernels is what I do), and I actually have absolutely zero interest in creating a traditional SCM system.” – Linus (http://marc.info/?l=linux-kernel&m=111314792424707)
  • 8. Git Design • Non-Linear Development • Distributed Development • Efficiency
  • 11. Internals - Git Objects • Git objects are the actual data of Git, the main thing that the repository is made up of • Each object is compressed (with Zlib) and referenced by the SHA-1 value of its contents plus a small header: • full SHA-1: dae86e1950b1277e545cee180551750029cfe735 • partial SHA-1: dae86e 
 • There are four main object types in Git: • Blob • Tree • Commit • Tag
  • 12. Internals - Working Directory
  • 20. Internals - Example • current repository with one commit • and its’ logical structure
  • 21. Internals - Example • modify lib/base/base_include.rb • add a release tag v0.1
  • 22. Internals - Example • modify init.rb
  • 23. Internals - Example • history view
  • 24. Internals - Example • git checkout v0.1
  • 25. Internals - Branching and Merging • Branches resident in .git/ refs/heads • Creating a branch is nothing more than just writing 40 characters to a file
  • 26. Internals - Remotes • origin/master • local master
  • 27. Internals - Remotes • origin/master • origin/idea • local master
  • 28. Internals - Merge • local master • tag T1 • feature branch experiment
  • 29. Internals - Merge • merge experiment into master • delete experiment branch
  • 30. Internals - Rebase • commits, pull and merge • history becomes worse and confusing
  • 31. Internals - Rebase • orphans Commit 1 • applies the changes between Commit 0 and Commit 1 to the files in Remote Commit 1 • creating a new Commit 2
  • 32. Internals - Rebase • as you’ll remember, you and Jen both commit again
  • 33. Internals - Rebase • rebase next two commits
  • 34. Internals - Rebase • rebase next two commits
  • 35. Internals - Rebase • rebase with linear history • merge sucks a lot
  • 37. Play with Git - config • git config —global user.name “Dylan” • git config —global user.email “dylanninin@gmail.com Or [user] name = Dylan email = dylanninin@gmail.com [core] excludesfile = ~/.gitignore editor = vim [alias] co = checkout [log] date = relative More such example • https://gist.github.com/pksunkara/988716 • ~/.gitconfig
  • 38. Play with Git - .git directory http://www.gitguys.com/topics/the-git-directory/
  • 39. Play with Git - model • repository/remote/workspace • index area
  • 40. Play with Git - work hard http://www.gitguys.com/topics/the-git-directory/
  • 41. Play with Git - help • git help <command>|<concept> • git help -a • git help -g The common Git guides are: attributes Defining attributes per path everyday Everyday Git With 20 Commands Or So glossary A Git glossary ignore Specifies intentionally untracked files to ignore modules Defining submodule properties revisions Specifying revisions and ranges for Git tutorial A tutorial introduction to Git (for version 1.5.1 or newer) workflows An overview of recommended workflows with Git 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept.
  • 45. Github Flow create a
 branch add 
 commits open a
 pull request discuss &
 review deploy merge
 into
 master
  • 46. In case of fire
  • 47. Q & A
  • 48. Reference • Git: https://en.wikipedia.org/wiki/Git_(software) • Linus on Git: https://www.youtube.com/watch?v=4XpnKHJAok8 • Pro Git: http://git-scm.com/book • Git Internals: http://git-scm.com/book/en/v1/Git-Internals • Peepcode Git Internals: https://github.com/pluralsight/git-internals-pdf • SHA-1: https://en.wikipedia.org/wiki/SHA-1 • Facebook’s git repo is 54GB: https://news.ycombinator.com/item?id=7648237 • Git Branching model: http://nvie.com/posts/a-successful-git-branching-model/ • Github Flow: 
 - http://scottchacon.com/2011/08/31/github-flow.html
 - https://guides.github.com/introduction/flow/