SlideShare ist ein Scribd-Unternehmen logo
1 von 48
GIT BASICS
                 Ariejan de Vroom – Kabisa ICT




http://kabisa.nl
http://ariejan.net
http://twitter.com/ariejan
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? Mercurial?
• 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   master




          c5   c6   new_feature
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   master




           c5   c6        new_feature
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    master




new_feature    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
USING TAGS

~/gitbasics $ git checkout -b fix_1.0 v1.0
Switched to branch "fix_1.0"

~/gitbasics $ git rebase v1.0

~/gitbasics $ git log v1.0..HEAD
TAGS @ GITHUB
BISECTING


• Binary search for a bad commit
• Find out where it when wrong (and who to
  blame!)
BISECTING

     v1.0        Good or Bad?        HEAD



c1   c2     c3   c4        c5   c6    c7
BISECTING
                      Good or
       v1.0                                HEAD
                       Bad?


 c1     c2    c3     c4     c5        c6   c7

~/gitbasics $ git bisect start
~/gitbasics $ git bisect bad
~/gitbasics $ git bisect good v1.0

~/gitbasics $ git bisect bad | good

~/gitbasics $ git bisect reset

~/gitbasics $ git bisect start HEAD v1.0
RELEASE
    MANAGEMENT

• Manage your DTSP environments
• Branches to the rescue!
RELEASE
             MANAGEMENT

~/gitbasics $ git branch production master

~/gitbasics $ git push origin production

~/gitbasics $ git checkout --track -b production origin/production
RELEASE
             MANAGEMENT

~/gitbasics $ git checkout production

~/gitbasics $ git rebase master

~/gitbasics $ git push origin production
TAGGING RELEASES

~/gitbasics $ git checkout master

~/gitbasics $ git tag -a -m "Tag v1.0.3" v1.0.3
~/gitbasics $ git push --tags

~/gitbasics $ git checkout production
~/gitbasics $ git rebase v1.0.3
~/gitbasics $ git push origin production
THE STASH


• Stash away uncommitted 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
GITHUB.COM

• Share your code!
• Hardcore forking action!
• Crowd Sourcing
NETWORK
NETWORK
FORKQUEUE
PULL REQUESTS


~/imdb $ git add -f boscomonkey 
git://github.com/boscomonkey/imdb.git
~/imdb $ git checkout -b boscomonkey/master
~/imdb $ git pull boscomonkey master

~/imdb $ git checkout master
~/imdb $ git merge boscomonkey/master
~/imdb $ git push
SURVEY


• Who is going to try Git?
• Stick with Subversion?
WE’RE HIRING!
  AWESOME CODERS


  recruitment@kabisa.nl
THANKS!
Slides will be posted to http://slideshare.net/ariejan
          Contact me at ariejan@kabisa.nl
     or follow me at http://twitter.com/ariejan

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git advanced
Git advancedGit advanced
Git advanced
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Git commands
Git commandsGit commands
Git commands
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git presentation
Git presentationGit presentation
Git presentation
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
 
git and github
git and githubgit and github
git and github
 

Andere mochten auch

Rega solutions ppt [compatibility mode]
Rega solutions ppt [compatibility mode]Rega solutions ppt [compatibility mode]
Rega solutions ppt [compatibility mode]rickkhosla
 
Innovation Holiday Cat
Innovation Holiday CatInnovation Holiday Cat
Innovation Holiday CatBiswajit Das
 
Leadership 2.0 April 2009 Edition
Leadership 2.0 April 2009 EditionLeadership 2.0 April 2009 Edition
Leadership 2.0 April 2009 Editionwestmv
 
Some of my Art
Some of my ArtSome of my Art
Some of my Artjhorton1
 
Introducing Joyful Leadership
Introducing Joyful LeadershipIntroducing Joyful Leadership
Introducing Joyful Leadershipwestmv
 
Git Basics Workshop Summer of Tech 2010
Git Basics Workshop Summer of Tech 2010Git Basics Workshop Summer of Tech 2010
Git Basics Workshop Summer of Tech 2010Y. Thong Kuah
 
Git Ready! Workflows
Git Ready! WorkflowsGit Ready! Workflows
Git Ready! WorkflowsAtlassian
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-BryanLearningTech
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagramsDilum Navanjana
 

Andere mochten auch (16)

Rega solutions ppt [compatibility mode]
Rega solutions ppt [compatibility mode]Rega solutions ppt [compatibility mode]
Rega solutions ppt [compatibility mode]
 
Innovation Holiday Cat
Innovation Holiday CatInnovation Holiday Cat
Innovation Holiday Cat
 
Leadership 2.0 April 2009 Edition
Leadership 2.0 April 2009 EditionLeadership 2.0 April 2009 Edition
Leadership 2.0 April 2009 Edition
 
Some of my Art
Some of my ArtSome of my Art
Some of my Art
 
Introducing Joyful Leadership
Introducing Joyful LeadershipIntroducing Joyful Leadership
Introducing Joyful Leadership
 
Git Basics Workshop Summer of Tech 2010
Git Basics Workshop Summer of Tech 2010Git Basics Workshop Summer of Tech 2010
Git Basics Workshop Summer of Tech 2010
 
Basic git-commands
Basic git-commandsBasic git-commands
Basic git-commands
 
Chest Pain
Chest PainChest Pain
Chest Pain
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Git basic
Git basicGit basic
Git basic
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Git Ready! Workflows
Git Ready! WorkflowsGit Ready! Workflows
Git Ready! Workflows
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
git flow
git flowgit flow
git flow
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 

Ähnlich wie GIT BASICS: A Crash Course on Version Control Fundamentals

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
 
Source control management
Source control managementSource control management
Source control managementOwen Winkler
 
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
 
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 for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffective
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using GitTony Hillerson
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffectiveUI
 

Ähnlich wie GIT BASICS: A Crash Course on Version Control Fundamentals (20)

Git Basics Philips
Git Basics PhilipsGit Basics Philips
Git Basics Philips
 
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
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Source control management
Source control managementSource control management
Source control management
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git
GitGit
Git
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
The git
The gitThe git
The git
 
Working with Git
Working with GitWorking with Git
Working with Git
 
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 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
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using Git
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 

Kürzlich hochgeladen

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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Kürzlich hochgeladen (20)

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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

GIT BASICS: A Crash Course on Version Control Fundamentals

  • 1. GIT BASICS Ariejan de Vroom – Kabisa ICT http://kabisa.nl http://ariejan.net http://twitter.com/ariejan
  • 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? Mercurial? • 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 master c5 c6 new_feature
  • 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 master c5 c6 new_feature
  • 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 master new_feature 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. USING TAGS ~/gitbasics $ git checkout -b fix_1.0 v1.0 Switched to branch "fix_1.0" ~/gitbasics $ git rebase v1.0 ~/gitbasics $ git log v1.0..HEAD
  • 32. BISECTING • Binary search for a bad commit • Find out where it when wrong (and who to blame!)
  • 33. BISECTING v1.0 Good or Bad? HEAD c1 c2 c3 c4 c5 c6 c7
  • 34. BISECTING Good or v1.0 HEAD Bad? c1 c2 c3 c4 c5 c6 c7 ~/gitbasics $ git bisect start ~/gitbasics $ git bisect bad ~/gitbasics $ git bisect good v1.0 ~/gitbasics $ git bisect bad | good ~/gitbasics $ git bisect reset ~/gitbasics $ git bisect start HEAD v1.0
  • 35. RELEASE MANAGEMENT • Manage your DTSP environments • Branches to the rescue!
  • 36. RELEASE MANAGEMENT ~/gitbasics $ git branch production master ~/gitbasics $ git push origin production ~/gitbasics $ git checkout --track -b production origin/production
  • 37. RELEASE MANAGEMENT ~/gitbasics $ git checkout production ~/gitbasics $ git rebase master ~/gitbasics $ git push origin production
  • 38. TAGGING RELEASES ~/gitbasics $ git checkout master ~/gitbasics $ git tag -a -m "Tag v1.0.3" v1.0.3 ~/gitbasics $ git push --tags ~/gitbasics $ git checkout production ~/gitbasics $ git rebase v1.0.3 ~/gitbasics $ git push origin production
  • 39. THE STASH • Stash away uncommitted changes • Ideal for quick bug fixes!
  • 40. 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
  • 41. GITHUB.COM • Share your code! • Hardcore forking action! • Crowd Sourcing
  • 45. PULL REQUESTS ~/imdb $ git add -f boscomonkey git://github.com/boscomonkey/imdb.git ~/imdb $ git checkout -b boscomonkey/master ~/imdb $ git pull boscomonkey master ~/imdb $ git checkout master ~/imdb $ git merge boscomonkey/master ~/imdb $ git push
  • 46. SURVEY • Who is going to try Git? • Stick with Subversion?
  • 47. WE’RE HIRING! AWESOME CODERS recruitment@kabisa.nl
  • 48. THANKS! Slides will be posted to http://slideshare.net/ariejan Contact me at ariejan@kabisa.nl or follow me at http://twitter.com/ariejan