SlideShare a Scribd company logo
1 of 41
GIT BASICS
by Ariejan de Vroom – Kabisa ICT
          30th Juny 2009
WHAT THE GIT?!

“I'm an egotistical bastard, and I name all my projects after
       myself. First Linux, now git.” – Linus Torvalds
GET GIT!
http://git-scm.com/
SURVEY

• Who is NOT using version control?
• SubVersion?
• Anything else?
WHY GIT?!
• Distributed Repositories
• Non-linear Development
• Very fast branching and merging
• Toolkit Design
• Scales
• Cryptographic authentication of history.
LET’S ROCK!

~/gitbasics $ git init
Initialized empty Git repository
in /Users/ariejan/gitbasics/.git/
LET’S ROLL!

~/gitbasics $ git clone
git@github.com/ariejan/gitbasics.git
~/gitbasics $ echo "Live long and prosper" > README
~/gitbasics $ git add README
~/gitbasics $ git commit -m "Added README"
[master (root-commit)]: created 8e60b09: "Added README"
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 README
WHAT JUST HAPPENED?

~/gitbasics $ git log

commit 8e60b09d3082e9473944075cc01b3b67bb97d5c3
Author: Ariejan de Vroom <ariejan@ariejan.net>
Date: Mon May 11 21:51:24 2009 +0200

  Added README
HOW GIT WORKS
    Working Directory

              git add


      Staging Area

              git commit


      Repository
WORKFLOW

• Hack! ( TextMate, vim, ... )
• Stage your changes ( git add )
• Review your changes ( git status | diff )
• Commit (locally) ( git commit )
• Repeat
USING BRANCHES

• Very, very fast
• Keep different code paths separate
• Try new things
• Atomic merges!
SURVEY

• How many of you use branching?
• Do you work exclusively on trunk/master?
• NEVER work on trunk/master?
BRANCHING

c1   c2   c3   c4




          c5   c6
LET’S BRANCH!
~/gitbasics $ git checkout -b new_feature
Switched to a new branch "new_feature"

~/gitbasics $ git branch
  master
* new_feature

~/gitbasics $ git checkout master
Switched to branch "master"

~/gitbasics $ git branch -d feature3
Deleted branch feature3
MERGING

• Merge two branches together
• Add new features
• Add bugs fixes
MERGING

c1   c2   c3   c4   c7




          c5   c6
MERGING

~/gitbasics $ git checkout master
Switched to branch "master"

~/gitbasics $ git merge new_feature
REBASING

• Bring a branch up-to-date
• Rebasing is rewriting history!
• Don’t use rebasing on a branch you’re
  sharing!
REBASING

c1   c2    c3    c4




           c3’   c4’   c5   c6
REBASING

~/gitbasics $ git checkout new_feature
Switched to branch "new_feature"

~/gitbasics $ git rebase master
REMOTE

• Store and share your code!
 • github.com
 • gitosis ( self-managed over SSH )
PUSH

~/gitbasics $ git add origin git@github.com/ariejan/
gitbasics.git

~/gitbasics $ git push origin master
FETCH / PULL


~/gitbasics $ git fetch origin

~/gitbasics $ git pull origin master
WORKFLOW
             Working Directory

add


                Staging Area

 commit                   checkout   merge


                Repository

      push               fetch           pull

                  Remote
TAGGING


• Mark a point in history
• Optionally sign it cryptographically with
  GnuPG
TAGGING
      v1.0




c1    c2     c3   c4
TAGGING

~/gitbasics $ git tag -a -m "Tag v1.0" v1.0
Switched to branch "new_feature"

~/gitbasics $ git tag
v1.0

~/gitbasics $ git push --tags
THE STASH


• Stash away uncommited changes
• Ideal for quick bug fixes!
THE STASH
~/gitbasics $ git status
#	 modified:   README

~/gitbasics $ git stash
~/gitbasics $ git status
nothing to commit

# Hack, stage, review, commit, etc.

~/gitbasics $ git stash pop
~/gitbasics $ git status
#	 modified:   README
CONFLICTS

• Conflicts happen
• Git is clever
• Easy to resolve manually
• Merges are atomic!
CONFLICTS
~/gitbasics $ git merge awesome_feature
Auto-merged README
CONFLICT (content): Merge conflict in README
Automatic merge failed; fix conflicts and
then commit the result.

~/gitbasics $ vim README
~/gitbasics $ git add README
~/gitbasics $ git commit -m “fixed merge
conflict”
GIT-SVN

It’s like being the Chuck Norris of the team!
ASSUME THIS
~/gitbasics $ svn log http://svnhub.com/project/trunk
------------------------------------------------------
r17048 | ariejan | 2009-06-30 ....

Updated README.




                                   SVN Repository courtesy of SVNHub.com
CHECKOUT

~ $ mkdir gitbasics
~ $ cd gitbasics
~/gitbasics $ git-svn init http://svnhub.com/project/
trunk

~/gitbasics $ git-svn fetch -r17048
   A    README
UPDATE


~/gitbasics $ git-svn rebase
COMMIT


~/gitbasics $ git-svn dcommit
WORKFLOW
~/gitbasics $ git-svn init URL
~/gitbasics $ git-svn rebase && git-svn fetch

~/gitbasics $ git checkout -b new_feature
~/gitbasics $ git add && git commit

~/gitbasics   $   git checkout master
~/gitbasics   $   git-svn rebase
~/gitbasics   $   git merge new_feature
~/gitbasics   $   git-svn dcommit
SURVEY

• Who is going to try Git?
• Stick with SubVersion?
• Try git-svn?
THANKS!

Slides will be published at http://slideshare.net/ariejan
            Contact me at ariejan@kabisa.nl

More Related Content

What's hot

Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open SourceLorna Mitchell
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubNick Quaranto
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
How we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyHow we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyMinqi Pan
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubBigBlueHat
 
COSCUP 2016: Project 52 每週一個小專案來學習 Golang
COSCUP 2016: Project 52 每週一個小專案來學習 GolangCOSCUP 2016: Project 52 每週一個小專案來學習 Golang
COSCUP 2016: Project 52 每週一個小專案來學習 GolangEvan Lin
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 

What's hot (20)

Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open Source
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Github basics
Github basicsGithub basics
Github basics
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
 
GitHub Presentation
GitHub PresentationGitHub Presentation
GitHub Presentation
 
Flow
FlowFlow
Flow
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
git and github
git and githubgit and github
git and github
 
How we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyHow we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee company
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Git'in on Windows
Git'in on WindowsGit'in on Windows
Git'in on Windows
 
COSCUP 2016: Project 52 每週一個小專案來學習 Golang
COSCUP 2016: Project 52 每週一個小專案來學習 GolangCOSCUP 2016: Project 52 每週一個小專案來學習 Golang
COSCUP 2016: Project 52 每週一個小專案來學習 Golang
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git'in in 15
Git'in in 15Git'in in 15
Git'in in 15
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Git Pull Requests
Git Pull RequestsGit Pull Requests
Git Pull Requests
 

Viewers also liked

140107網路創業者需要注意的著作權法問題
140107網路創業者需要注意的著作權法問題140107網路創業者需要注意的著作權法問題
140107網路創業者需要注意的著作權法問題Wenchi Lai
 
AtticTV and NodeJS
AtticTV and NodeJSAtticTV and NodeJS
AtticTV and NodeJSGrey Ang
 
Rock with knockout
Rock with knockoutRock with knockout
Rock with knockoutKirk Chen
 

Viewers also liked (6)

140107網路創業者需要注意的著作權法問題
140107網路創業者需要注意的著作權法問題140107網路創業者需要注意的著作權法問題
140107網路創業者需要注意的著作權法問題
 
Diapexporock
DiapexporockDiapexporock
Diapexporock
 
AtticTV and NodeJS
AtticTV and NodeJSAtticTV and NodeJS
AtticTV and NodeJS
 
Diap Acid Vicious
Diap Acid ViciousDiap Acid Vicious
Diap Acid Vicious
 
Rock with knockout
Rock with knockoutRock with knockout
Rock with knockout
 
AppDC 03, App x Design, Tony, Mobile 情感設計
AppDC 03, App x Design, Tony, Mobile 情感設計AppDC 03, App x Design, Tony, Mobile 情感設計
AppDC 03, App x Design, Tony, Mobile 情感設計
 

Similar to Git Basics Philips

Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails UndergroundAriejan de Vroom
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Ariejan de Vroom
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Bosstmacwilliam
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
Source control management
Source control managementSource control management
Source control managementOwen Winkler
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
Git Obstacle Course: Stop BASHing your head and break down the basics
Git Obstacle Course: Stop BASHing your head and break down the basicsGit Obstacle Course: Stop BASHing your head and break down the basics
Git Obstacle Course: Stop BASHing your head and break down the basicsChris Bohatka
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexyAilsa126
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 

Similar to Git Basics Philips (20)

Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Source control management
Source control managementSource control management
Source control management
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git Obstacle Course: Stop BASHing your head and break down the basics
Git Obstacle Course: Stop BASHing your head and break down the basicsGit Obstacle Course: Stop BASHing your head and break down the basics
Git Obstacle Course: Stop BASHing your head and break down the basics
 
The git
The gitThe git
The git
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
 
Basic git
Basic gitBasic git
Basic git
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 

Recently uploaded

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

Git Basics Philips

  • 1. GIT BASICS by Ariejan de Vroom – Kabisa ICT 30th Juny 2009
  • 2. WHAT THE GIT?! “I'm an egotistical bastard, and I name all my projects after myself. First Linux, now git.” – Linus Torvalds
  • 4.
  • 5. SURVEY • Who is NOT using version control? • SubVersion? • Anything else?
  • 6. WHY GIT?! • Distributed Repositories • Non-linear Development • Very fast branching and merging • Toolkit Design • Scales • Cryptographic authentication of history.
  • 7. LET’S ROCK! ~/gitbasics $ git init Initialized empty Git repository in /Users/ariejan/gitbasics/.git/
  • 8. LET’S ROLL! ~/gitbasics $ git clone git@github.com/ariejan/gitbasics.git
  • 9. ~/gitbasics $ echo "Live long and prosper" > README ~/gitbasics $ git add README ~/gitbasics $ git commit -m "Added README" [master (root-commit)]: created 8e60b09: "Added README" 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README
  • 10. WHAT JUST HAPPENED? ~/gitbasics $ git log commit 8e60b09d3082e9473944075cc01b3b67bb97d5c3 Author: Ariejan de Vroom <ariejan@ariejan.net> Date: Mon May 11 21:51:24 2009 +0200 Added README
  • 11. HOW GIT WORKS Working Directory git add Staging Area git commit Repository
  • 12. WORKFLOW • Hack! ( TextMate, vim, ... ) • Stage your changes ( git add ) • Review your changes ( git status | diff ) • Commit (locally) ( git commit ) • Repeat
  • 13. USING BRANCHES • Very, very fast • Keep different code paths separate • Try new things • Atomic merges!
  • 14. SURVEY • How many of you use branching? • Do you work exclusively on trunk/master? • NEVER work on trunk/master?
  • 15. BRANCHING c1 c2 c3 c4 c5 c6
  • 16. LET’S BRANCH! ~/gitbasics $ git checkout -b new_feature Switched to a new branch "new_feature" ~/gitbasics $ git branch master * new_feature ~/gitbasics $ git checkout master Switched to branch "master" ~/gitbasics $ git branch -d feature3 Deleted branch feature3
  • 17. MERGING • Merge two branches together • Add new features • Add bugs fixes
  • 18. MERGING c1 c2 c3 c4 c7 c5 c6
  • 19. MERGING ~/gitbasics $ git checkout master Switched to branch "master" ~/gitbasics $ git merge new_feature
  • 20. REBASING • Bring a branch up-to-date • Rebasing is rewriting history! • Don’t use rebasing on a branch you’re sharing!
  • 21. REBASING c1 c2 c3 c4 c3’ c4’ c5 c6
  • 22. REBASING ~/gitbasics $ git checkout new_feature Switched to branch "new_feature" ~/gitbasics $ git rebase master
  • 23. REMOTE • Store and share your code! • github.com • gitosis ( self-managed over SSH )
  • 24. PUSH ~/gitbasics $ git add origin git@github.com/ariejan/ gitbasics.git ~/gitbasics $ git push origin master
  • 25. FETCH / PULL ~/gitbasics $ git fetch origin ~/gitbasics $ git pull origin master
  • 26. WORKFLOW Working Directory add Staging Area commit checkout merge Repository push fetch pull Remote
  • 27. TAGGING • Mark a point in history • Optionally sign it cryptographically with GnuPG
  • 28. TAGGING v1.0 c1 c2 c3 c4
  • 29. TAGGING ~/gitbasics $ git tag -a -m "Tag v1.0" v1.0 Switched to branch "new_feature" ~/gitbasics $ git tag v1.0 ~/gitbasics $ git push --tags
  • 30. THE STASH • Stash away uncommited changes • Ideal for quick bug fixes!
  • 31. THE STASH ~/gitbasics $ git status # modified: README ~/gitbasics $ git stash ~/gitbasics $ git status nothing to commit # Hack, stage, review, commit, etc. ~/gitbasics $ git stash pop ~/gitbasics $ git status # modified: README
  • 32. CONFLICTS • Conflicts happen • Git is clever • Easy to resolve manually • Merges are atomic!
  • 33. CONFLICTS ~/gitbasics $ git merge awesome_feature Auto-merged README CONFLICT (content): Merge conflict in README Automatic merge failed; fix conflicts and then commit the result. ~/gitbasics $ vim README ~/gitbasics $ git add README ~/gitbasics $ git commit -m “fixed merge conflict”
  • 34. GIT-SVN It’s like being the Chuck Norris of the team!
  • 35. ASSUME THIS ~/gitbasics $ svn log http://svnhub.com/project/trunk ------------------------------------------------------ r17048 | ariejan | 2009-06-30 .... Updated README. SVN Repository courtesy of SVNHub.com
  • 36. CHECKOUT ~ $ mkdir gitbasics ~ $ cd gitbasics ~/gitbasics $ git-svn init http://svnhub.com/project/ trunk ~/gitbasics $ git-svn fetch -r17048 A README
  • 39. WORKFLOW ~/gitbasics $ git-svn init URL ~/gitbasics $ git-svn rebase && git-svn fetch ~/gitbasics $ git checkout -b new_feature ~/gitbasics $ git add && git commit ~/gitbasics $ git checkout master ~/gitbasics $ git-svn rebase ~/gitbasics $ git merge new_feature ~/gitbasics $ git-svn dcommit
  • 40. SURVEY • Who is going to try Git? • Stick with SubVersion? • Try git-svn?
  • 41. THANKS! Slides will be published at http://slideshare.net/ariejan Contact me at ariejan@kabisa.nl