SlideShare una empresa de Scribd logo
1 de 41
Introduction to git


Lukas Fittl    29th June 2010
Part 1: Theory
git is really intelligent, and
            beautiful.

But it takes some time to fully grasp the way it works.

  Just ask if you need help with your understanding.
The SVN model
                    Server
                  Repository




     svn commit                svn update



                                   Your
          You
                                 colleague




Commits are only shared through the server.
The Git model
            “origin”
           Repository




git push                git pull



                           Your
    You
                         colleague
The Git model
                            “origin”
                           Repository




          git push                         git pull


                         git push REMOTE
                                               Your
              Your
                                            colleague’s
            Repository
                                            repository
                         git pull REMOTE




You can push/pull commits to any remote repository,
  there is no difference between server and client.
So how does that
     work?
First of all, definitions:
•   Working tree
    A directory in your filesystem that is associated with a
    repository, containing files & sub-directories.

•   Repository
    A collection of commits & branches, saved in the .git
    directory.

•   Commit
    A snapshot of your working tree at a certain point in
    time, identified by a revision number.

•   HEAD
    The name for the commit thats currently checked out in
Revision Numbering
• Every commit gets a globally unique
  identifier, not a simple revision number
  git log 00de993ae4a12f286da8bdf24b041c2e8dfc4e3b
  vs
  svn log -r3129


• For commands you can also cut off the end
  of the identifier, as long as that is still
  unique within your repository
  git log 00de993ae4
git clone

   is your starting point for working with
                 existing code

It creates a local repository for you, copying
    & tracking the master branch from the
               specified location.
git clone git@github.com:lfittl/browscap.git ruby-browscap
Remotes
• By default you’ll only have the “origin”
  remote repository, which is the repository
  you did git clone from.

• List existing remotes using git   remote

• Showremote with NAME
  git
         details
                 show

• Add new remotes using
  git remote add NAME       URL
Commits = local
•   git commit only affects your repository,
    not the origin or any other remote
    repository
•   git push in order to share your commits

• Commits are cheap & fast
• Commit as often as possible!
The index
• When you edit/add/remove files, only your
    working tree changes
• To commit changes, you first save them in
    the index with git add or git rm
•   git status shows the current index

•   git commit commits only the changes
    saved in the index, and clears the index
    afterwards
But there’s also git commit -a to commit
all unsaved working tree changes without
         adding them to the index.



   * You still have to use git   rm   for removing files
And don’t forget to

   git push
Also there is

          git log
         git diff
       git annotate


And they do what you expect.

     man git-annotate
            ...


     is also your friend.
Branching
    &
 Merging
Branches are cheap.
Merging just works.
Branch
     =
Named commit
Per default you always work on the
          master branch.
git branch

 shows you the branch you are currently on
(marked with *) & lists the available branches
A branch is local to your repository,
create as many or as little as you like.
Create a new one:
   git branch BRANCH



Checkout an existing one:
  git checkout BRANCH
You can also push all commits of your
 current branch to a remote branch:

      git push REMOTE BRANCH

      git push origin master
             git push
Or checkout someone else’s branch,
 work on it, and then share your
             changes:

         git branch -r
   git checkout REMOTE_BRANCH
       git branch BRANCH
               ...
            git push
git merge BRANCH

Merges the specified branch into your
          current branch.

 You must have a common ancestor.

If the merge fails, use git status to see
    the conflicts, edit the files, git add
        them and then git commit.
You can delete the merged branch
             afterwards:
              git branch -d BRANCH


git will complain if this would result in lost changes (use -D to override).
git push REMOTE :REMOTE_BRANCH

   to delete a remote branch.

                       Careful!
  This won’t check whether the branch is already merged.
Tips & Tricks
git gui

is your friend, especially when
       you’re confused.
git checkout FILENAME

to revert a file changed in the working
          tree back to HEAD
           Only if you didn’t commit yet.
git revert REVISION

    to revert a complete revision.

Creates a new commit that removes the
               changes.
.gitignore
        instead of
svn propset svn:ignore
Single .git directory in the root directory,
    instead of multiple .svn directories
Most relevant configuration is stored in the

                .git/config
         remotes, author name/email, etc.
git stash
git submodule
git cherry-pick
Part 2: Workshop
Further information
•   Git - SVN Crash Course
    http://git.or.cz/course/svn.html


•   The Git Community Book
    http://book.git-scm.com/index.html


•   John Wiegley: Git from the bottom up
    http://ftp.newartisans.com/pub/git.from.bottom.up.pdf


•   Github: a social source-code sharing site
    http://github.com/

Más contenido relacionado

La actualidad más candente

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to gitEmanuele Olivetti
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeMd Swawibe Ul Alam
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version ControlSourabh Sahu
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction TutorialThomas Rausch
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 

La actualidad más candente (20)

Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
git and github
git and githubgit and github
git and github
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git basics
Git basicsGit basics
Git basics
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Git
GitGit
Git
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 

Similar a Introduction to Git

Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideRaghavendraVattikuti1
 
Git basics a starter on git and its ecosystem
Git basics  a starter on git and its ecosystemGit basics  a starter on git and its ecosystem
Git basics a starter on git and its ecosystemFrançois D'Agostini
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanJames Ford
 
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 for developers
Git for developersGit for developers
Git for developersHacen Dadda
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-BryanLearningTech
 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Ahmed El-Arabawy
 
Git slides
Git slidesGit slides
Git slidesNanyak S
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko
 
Source control management
Source control managementSource control management
Source control managementOwen Winkler
 

Similar a Introduction to Git (20)

Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
 
Git 101
Git 101Git 101
Git 101
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
 
Git basics a starter on git and its ecosystem
Git basics  a starter on git and its ecosystemGit basics  a starter on git and its ecosystem
Git basics a starter on git and its ecosystem
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
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 basic
Git basicGit basic
Git basic
 
Git for developers
Git for developersGit for developers
Git for developers
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Session git
Session gitSession git
Session git
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
 
Git
GitGit
Git
 
Git slides
Git slidesGit slides
Git slides
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015
 
Source control management
Source control managementSource control management
Source control management
 

Más de Lukas Fittl

Advanced pg_stat_statements: Filtering, Regression Testing & more
Advanced pg_stat_statements: Filtering, Regression Testing & moreAdvanced pg_stat_statements: Filtering, Regression Testing & more
Advanced pg_stat_statements: Filtering, Regression Testing & moreLukas Fittl
 
Lean Startup & UX for Agile Teams
Lean Startup & UX for Agile TeamsLean Startup & UX for Agile Teams
Lean Startup & UX for Agile TeamsLukas Fittl
 
Lean Stack - A Story Of Continuous Improvement
Lean Stack - A Story Of Continuous ImprovementLean Stack - A Story Of Continuous Improvement
Lean Stack - A Story Of Continuous ImprovementLukas Fittl
 
Lean & Agile ♥ UX Design
Lean & Agile ♥ UX DesignLean & Agile ♥ UX Design
Lean & Agile ♥ UX DesignLukas Fittl
 
We Built It, And They Didn't Come!
We Built It, And They Didn't Come!We Built It, And They Didn't Come!
We Built It, And They Didn't Come!Lukas Fittl
 
Actionable Metrics @ Lean Startup Meetup Berlin
Actionable Metrics @ Lean Startup Meetup BerlinActionable Metrics @ Lean Startup Meetup Berlin
Actionable Metrics @ Lean Startup Meetup BerlinLukas Fittl
 
Enabling Innovation using Lean Startup
Enabling Innovation using Lean StartupEnabling Innovation using Lean Startup
Enabling Innovation using Lean StartupLukas Fittl
 
Lean Startup Essentials - March 2012
Lean Startup Essentials - March 2012Lean Startup Essentials - March 2012
Lean Startup Essentials - March 2012Lukas Fittl
 
Lean Startup Essentials - Le Camping Edition
Lean Startup Essentials - Le Camping EditionLean Startup Essentials - Le Camping Edition
Lean Startup Essentials - Le Camping EditionLukas Fittl
 
Lean Startup Essentials - SeedHack Edition
Lean Startup Essentials - SeedHack EditionLean Startup Essentials - SeedHack Edition
Lean Startup Essentials - SeedHack EditionLukas Fittl
 
Lean Startup Essentials - STARTup Live Hagenberg
Lean Startup Essentials - STARTup Live HagenbergLean Startup Essentials - STARTup Live Hagenberg
Lean Startup Essentials - STARTup Live HagenbergLukas Fittl
 
Lean Startup Essentials - STARTup Live Graz
Lean Startup Essentials - STARTup Live GrazLean Startup Essentials - STARTup Live Graz
Lean Startup Essentials - STARTup Live GrazLukas Fittl
 

Más de Lukas Fittl (12)

Advanced pg_stat_statements: Filtering, Regression Testing & more
Advanced pg_stat_statements: Filtering, Regression Testing & moreAdvanced pg_stat_statements: Filtering, Regression Testing & more
Advanced pg_stat_statements: Filtering, Regression Testing & more
 
Lean Startup & UX for Agile Teams
Lean Startup & UX for Agile TeamsLean Startup & UX for Agile Teams
Lean Startup & UX for Agile Teams
 
Lean Stack - A Story Of Continuous Improvement
Lean Stack - A Story Of Continuous ImprovementLean Stack - A Story Of Continuous Improvement
Lean Stack - A Story Of Continuous Improvement
 
Lean & Agile ♥ UX Design
Lean & Agile ♥ UX DesignLean & Agile ♥ UX Design
Lean & Agile ♥ UX Design
 
We Built It, And They Didn't Come!
We Built It, And They Didn't Come!We Built It, And They Didn't Come!
We Built It, And They Didn't Come!
 
Actionable Metrics @ Lean Startup Meetup Berlin
Actionable Metrics @ Lean Startup Meetup BerlinActionable Metrics @ Lean Startup Meetup Berlin
Actionable Metrics @ Lean Startup Meetup Berlin
 
Enabling Innovation using Lean Startup
Enabling Innovation using Lean StartupEnabling Innovation using Lean Startup
Enabling Innovation using Lean Startup
 
Lean Startup Essentials - March 2012
Lean Startup Essentials - March 2012Lean Startup Essentials - March 2012
Lean Startup Essentials - March 2012
 
Lean Startup Essentials - Le Camping Edition
Lean Startup Essentials - Le Camping EditionLean Startup Essentials - Le Camping Edition
Lean Startup Essentials - Le Camping Edition
 
Lean Startup Essentials - SeedHack Edition
Lean Startup Essentials - SeedHack EditionLean Startup Essentials - SeedHack Edition
Lean Startup Essentials - SeedHack Edition
 
Lean Startup Essentials - STARTup Live Hagenberg
Lean Startup Essentials - STARTup Live HagenbergLean Startup Essentials - STARTup Live Hagenberg
Lean Startup Essentials - STARTup Live Hagenberg
 
Lean Startup Essentials - STARTup Live Graz
Lean Startup Essentials - STARTup Live GrazLean Startup Essentials - STARTup Live Graz
Lean Startup Essentials - STARTup Live Graz
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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...Enterprise Knowledge
 
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 MenDelhi Call girls
 
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 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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 Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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...Drew Madelung
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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)wesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Último (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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...
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Introduction to Git

  • 1. Introduction to git Lukas Fittl 29th June 2010
  • 3. git is really intelligent, and beautiful. But it takes some time to fully grasp the way it works. Just ask if you need help with your understanding.
  • 4. The SVN model Server Repository svn commit svn update Your You colleague Commits are only shared through the server.
  • 5. The Git model “origin” Repository git push git pull Your You colleague
  • 6. The Git model “origin” Repository git push git pull git push REMOTE Your Your colleague’s Repository repository git pull REMOTE You can push/pull commits to any remote repository, there is no difference between server and client.
  • 7. So how does that work?
  • 8. First of all, definitions: • Working tree A directory in your filesystem that is associated with a repository, containing files & sub-directories. • Repository A collection of commits & branches, saved in the .git directory. • Commit A snapshot of your working tree at a certain point in time, identified by a revision number. • HEAD The name for the commit thats currently checked out in
  • 9. Revision Numbering • Every commit gets a globally unique identifier, not a simple revision number git log 00de993ae4a12f286da8bdf24b041c2e8dfc4e3b vs svn log -r3129 • For commands you can also cut off the end of the identifier, as long as that is still unique within your repository git log 00de993ae4
  • 10. git clone is your starting point for working with existing code It creates a local repository for you, copying & tracking the master branch from the specified location. git clone git@github.com:lfittl/browscap.git ruby-browscap
  • 11. Remotes • By default you’ll only have the “origin” remote repository, which is the repository you did git clone from. • List existing remotes using git remote • Showremote with NAME git details show • Add new remotes using git remote add NAME URL
  • 12. Commits = local • git commit only affects your repository, not the origin or any other remote repository • git push in order to share your commits • Commits are cheap & fast • Commit as often as possible!
  • 13. The index • When you edit/add/remove files, only your working tree changes • To commit changes, you first save them in the index with git add or git rm • git status shows the current index • git commit commits only the changes saved in the index, and clears the index afterwards
  • 14. But there’s also git commit -a to commit all unsaved working tree changes without adding them to the index. * You still have to use git rm for removing files
  • 15. And don’t forget to git push
  • 16. Also there is git log git diff git annotate And they do what you expect. man git-annotate ... is also your friend.
  • 17. Branching & Merging
  • 20. Branch = Named commit
  • 21. Per default you always work on the master branch.
  • 22. git branch shows you the branch you are currently on (marked with *) & lists the available branches
  • 23. A branch is local to your repository, create as many or as little as you like.
  • 24. Create a new one: git branch BRANCH Checkout an existing one: git checkout BRANCH
  • 25. You can also push all commits of your current branch to a remote branch: git push REMOTE BRANCH git push origin master git push
  • 26. Or checkout someone else’s branch, work on it, and then share your changes: git branch -r git checkout REMOTE_BRANCH git branch BRANCH ... git push
  • 27. git merge BRANCH Merges the specified branch into your current branch. You must have a common ancestor. If the merge fails, use git status to see the conflicts, edit the files, git add them and then git commit.
  • 28. You can delete the merged branch afterwards: git branch -d BRANCH git will complain if this would result in lost changes (use -D to override).
  • 29. git push REMOTE :REMOTE_BRANCH to delete a remote branch. Careful! This won’t check whether the branch is already merged.
  • 31. git gui is your friend, especially when you’re confused.
  • 32. git checkout FILENAME to revert a file changed in the working tree back to HEAD Only if you didn’t commit yet.
  • 33. git revert REVISION to revert a complete revision. Creates a new commit that removes the changes.
  • 34. .gitignore instead of svn propset svn:ignore
  • 35. Single .git directory in the root directory, instead of multiple .svn directories
  • 36. Most relevant configuration is stored in the .git/config remotes, author name/email, etc.
  • 41. Further information • Git - SVN Crash Course http://git.or.cz/course/svn.html • The Git Community Book http://book.git-scm.com/index.html • John Wiegley: Git from the bottom up http://ftp.newartisans.com/pub/git.from.bottom.up.pdf • Github: a social source-code sharing site http://github.com/

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n