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

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
Nick Quaranto
 

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 (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

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
Robert Lee-Cann
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
Ailsa126
 

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

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

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