SlideShare a Scribd company logo
1 of 75
Download to read offline
Version Control
Basics of Git




                   References:
                 http://gitref.org
Feb. 23, 2013   http://git-scm.com
Outline
       •   What is Version Control
       •   Why Version Control
       •   Git as Version Control Tool




Feb. 23, 2013
What




Feb. 23, 2013
What
        Version Control




Feb. 23, 2013
What
        Version Control
                lets you track your files




Feb. 23, 2013
What
        Version Control
                lets you track your files




                   so when you mess up you can easily
                   get back to a previous working version


Feb. 23, 2013
Why




Feb. 23, 2013
Why
       •   Backup and Restore




Feb. 23, 2013
Why
       •   Backup and Restore
       •   Synchronization




Feb. 23, 2013
Why
       •   Backup and Restore
       •   Synchronization
       •   Track Changes




Feb. 23, 2013
Why
       •   Backup and Restore
       •   Synchronization
       •   Track Changes
       •   Track Ownership



Feb. 23, 2013
How
      •   Repository
                where files are being stored

      •   Local Repository
                repository in the local machine

      •   Remote Repository
                are versions of your project that are hosted over the Internet or
                network somewhere



Feb. 23, 2013
Git: Basics




Feb. 23, 2013
Git: Basics
       •   Get / Create Repository




Feb. 23, 2013
Git: Basics
       •   Get / Create Repository
       •   Record Changes




Feb. 23, 2013
Git: Basics
       •   Get / Create Repository
       •   Record Changes
       • Track   History




Feb. 23, 2013
Git: Basics
       •   Get / Create Repository
       •   Record Changes
       • Track   History
       •   Undo Things




Feb. 23, 2013
Git: Basics
       •   Get / Create Repository
       •   Record Changes
       • Track   History
       •   Undo Things
       •   Sharing / Updating Files



Feb. 23, 2013
git-clone
                working                  staging                                          remote
                                                             local repo
                directory                 area                                             repo

                            git-add            git-commit                 git-push



                             git-reset                                    git-fetch


                                      git-checkout


                                                                             git-pull


                                              git-diff


                                               git-diff --staged



Feb. 23, 2013
Feb. 23, 2013
Create / Get




Feb. 23, 2013
Create / Get
       •   get remote repository




Feb. 23, 2013
Create / Get
       •   get remote repository
                git clone [repository url] [destination]




Feb. 23, 2013
Create / Get
       •   get remote repository
                git clone [repository url] [destination]

       •   existing directory




Feb. 23, 2013
Create / Get
       •   get remote repository
                git clone [repository url] [destination]

       •   existing directory
                git init [path/to/directory|file]




Feb. 23, 2013
Record Changes




Feb. 23, 2013
Record Changes
       •   Tracked Files




Feb. 23, 2013
Record Changes
       •   Tracked Files
                Files that are currently in the
                repository




Feb. 23, 2013
Record Changes
       •   Tracked Files
                Files that are currently in the
                repository
                 - unmodified, modified, staged




Feb. 23, 2013
Record Changes
       •   Tracked Files
                Files that are currently in the
                repository
                 - unmodified, modified, staged


       •   Untracked Files



Feb. 23, 2013
Record Changes
       •   Tracked Files
                Files that are currently in the
                repository
                 - unmodified, modified, staged


       •   Untracked Files
                Everything else


Feb. 23, 2013
Tracking New Files




Feb. 23, 2013
Tracking New Files
       git add [path/to/file|directory]




Feb. 23, 2013
Tracking New Files
       git add [path/to/file|directory]




       git-add command adds files to the staging area


Feb. 23, 2013
Committing Staged Files




Feb. 23, 2013
Committing Staged Files
       git commit -m "message"




Feb. 23, 2013
Committing Staged Files
       git commit -m "message"




       git-commit command commits all staged files


Feb. 23, 2013
Ignoring Files




Feb. 23, 2013
Ignoring Files
       •   Blank lines or lines starting with # are ignored.




Feb. 23, 2013
Ignoring Files
       •   Blank lines or lines starting with # are ignored.
       •   Standard glob patterns work.




Feb. 23, 2013
Ignoring Files
       •   Blank lines or lines starting with # are ignored.
       •   Standard glob patterns work.
       • You can end patterns with a forward slash
       (/) to specify a directory.




Feb. 23, 2013
Ignoring Files
       •   Blank lines or lines starting with # are ignored.
       •   Standard glob patterns work.
       • You can end patterns with a forward slash
       (/) to specify a directory.
       •You can negate a pattern by starting it with
       an exclamation point (!).


Feb. 23, 2013
Staged and Unstaged Changes




Feb. 23, 2013
Staged and Unstaged Changes
        git diff




Feb. 23, 2013
Staged and Unstaged Changes
        git diff
                 shows diff of what is modified but unstaged




Feb. 23, 2013
Staged and Unstaged Changes
        git diff
                 shows diff of what is modified but unstaged



        git diff --staged




Feb. 23, 2013
Staged and Unstaged Changes
        git diff
                 shows diff of what is modified but unstaged



        git diff --staged
                shows the changes that will currently go into the next commit.




Feb. 23, 2013
Removing Files

Renaming Files


Tracking History

Feb. 23, 2013
Removing Files
        git rm [file/directory]

Renaming Files


Tracking History

Feb. 23, 2013
Removing Files
        git rm [file/directory]

Renaming Files
        git mv current_file_name new_file_name


Tracking History

Feb. 23, 2013
Removing Files
        git rm [file/directory]

Renaming Files
        git mv current_file_name new_file_name


Tracking History
         git log

Feb. 23, 2013
Undoing Things




Feb. 23, 2013
Undoing Things
        •   Unstaging staged file




Feb. 23, 2013
Undoing Things
        •   Unstaging staged file
                git reset HEAD <file>




Feb. 23, 2013
Undoing Things
        •   Unstaging staged file
                git reset HEAD <file>

        •   Unmodifying modified file




Feb. 23, 2013
Undoing Things
        •   Unstaging staged file
                git reset HEAD <file>

        •   Unmodifying modified file
                git checkout -- <file>




Feb. 23, 2013
Undoing Things
        •   Unstaging staged file
                git reset HEAD <file>

        •   Unmodifying modified file
                git checkout -- <file>


        These commands are actually suggested when running git-status command



Feb. 23, 2013
Sharing / Updating Files




Feb. 23, 2013
Sharing / Updating Files
        Remote Repositories




Feb. 23, 2013
Sharing / Updating Files
        Remote Repositories
               are versions of your project that are hosted over the
            Internet or network somewhere.




Feb. 23, 2013
Sharing / Updating Files
        Remote Repositories
               are versions of your project that are hosted over the
            Internet or network somewhere.


                        • Show remote repository




Feb. 23, 2013
Sharing / Updating Files
        Remote Repositories
               are versions of your project that are hosted over the
            Internet or network somewhere.


                        • Show remote repository
                        • Add remote repository




Feb. 23, 2013
Sharing / Updating Files
        Remote Repositories
               are versions of your project that are hosted over the
            Internet or network somewhere.


                        • Show remote repository
                        • Add remote repository
                        • Update/Sync remote repository



Feb. 23, 2013
Sharing / Updating Files
        Remote Repositories
               are versions of your project that are hosted over the
            Internet or network somewhere.


                        • Show remote repository
                        • Add remote repository
                        • Update/Sync remote repository
                        • Inspect remote repository


Feb. 23, 2013
Remote Repository




Feb. 23, 2013
Remote Repository
      •   Show remote repository




Feb. 23, 2013
Remote Repository
      •   Show remote repository
            git remote -v




Feb. 23, 2013
Remote Repository
      • Show remote repository
          git remote -v
      • Add remote repository




Feb. 23, 2013
Remote Repository
      • Show remote repository
          git remote -v
      • Add remote repository

          git remote add [alias] [repository url]




Feb. 23, 2013
Remote Repository
      • Show remote repository
          git remote -v
      • Add remote repository

          git remote add [alias] [repository url]
      • Update remote repository




Feb. 23, 2013
Remote Repository
      • Show remote repository
          git remote -v
      • Add remote repository

          git remote add [alias] [repository url]
      • Update remote repository

          git push [alias] [branch]




Feb. 23, 2013
Remote Repository
      • Show remote repository
          git remote -v
      • Add remote repository

          git remote add [alias] [repository url]
      • Update remote repository

          git push [alias] [branch]
      • Sync with remote




Feb. 23, 2013
Remote Repository
      • Show remote repository
          git remote -v
      • Add remote repository

          git remote add [alias] [repository url]
      • Update remote repository

          git push [alias] [branch]
      • Sync with remote

          git pull [alias] [branch]




Feb. 23, 2013
Remote Repository
      • Show remote repository
           git remote -v
      • Add remote repository

           git remote add [alias] [repository url]
      • Update remote repository

           git push [alias] [branch]
      • Sync with remote

           git pull [alias] [branch]
      • Inspect remote repository




Feb. 23, 2013
Remote Repository
      • Show remote repository
           git remote -v
      • Add remote repository

           git remote add [alias] [repository url]
      • Update remote repository

           git push [alias] [branch]
      • Sync with remote

           git pull [alias] [branch]
      • Inspect remote repository

           git remote show [alias]


Feb. 23, 2013

More Related Content

What's hot

Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
Terry Wang
 

What's hot (20)

Git, Beginner to Advanced Survey
Git, Beginner to Advanced SurveyGit, Beginner to Advanced Survey
Git, Beginner to Advanced Survey
 
Git
GitGit
Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
 
Git Real
Git RealGit Real
Git Real
 
Git introduction
Git introductionGit introduction
Git introduction
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git is my hero
Git is my heroGit is my hero
Git is my hero
 
Git
GitGit
Git
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
From svn to git
From svn to gitFrom svn to git
From svn to git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Git 101
Git 101Git 101
Git 101
 
Git it on (includes git hub)
Git it on (includes git hub)Git it on (includes git hub)
Git it on (includes git hub)
 

Viewers also liked

Htmlcs spresentation
Htmlcs spresentationHtmlcs spresentation
Htmlcs spresentation
gaplabs
 
Jquery at-webcamp
Jquery at-webcampJquery at-webcamp
Jquery at-webcamp
gaplabs
 
PHP Web Development
PHP Web DevelopmentPHP Web Development
PHP Web Development
gaplabs
 
Zasady gry kasyno 1
Zasady gry kasyno 1Zasady gry kasyno 1
Zasady gry kasyno 1
Arek00
 

Viewers also liked (10)

Role of attorneys
Role of attorneysRole of attorneys
Role of attorneys
 
Htmlcs spresentation
Htmlcs spresentationHtmlcs spresentation
Htmlcs spresentation
 
Jquery at-webcamp
Jquery at-webcampJquery at-webcamp
Jquery at-webcamp
 
Welcome to Sofitel Lyon Bellecour
Welcome to Sofitel Lyon BellecourWelcome to Sofitel Lyon Bellecour
Welcome to Sofitel Lyon Bellecour
 
Organise your next event at Sofitel Lyon Bellecour
Organise your next event at Sofitel Lyon BellecourOrganise your next event at Sofitel Lyon Bellecour
Organise your next event at Sofitel Lyon Bellecour
 
PHP Web Development
PHP Web DevelopmentPHP Web Development
PHP Web Development
 
Техническая SEO оптимизация интернет магазинов
Техническая SEO оптимизация интернет магазиновТехническая SEO оптимизация интернет магазинов
Техническая SEO оптимизация интернет магазинов
 
Zasady gry kasyno 1
Zasady gry kasyno 1Zasady gry kasyno 1
Zasady gry kasyno 1
 
Урок 75 продвижение автомобильных сайтов
Урок 75 продвижение автомобильных сайтовУрок 75 продвижение автомобильных сайтов
Урок 75 продвижение автомобильных сайтов
 
Продвижение интернет магазинов 2013 Екатеринбург Iexpo 2013
Продвижение интернет магазинов 2013 Екатеринбург Iexpo 2013Продвижение интернет магазинов 2013 Екатеринбург Iexpo 2013
Продвижение интернет магазинов 2013 Екатеринбург Iexpo 2013
 

Similar to Version control

Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
Medhat Dawoud
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
 
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
 

Similar to Version control (20)

sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
 
Distributed Developer Workflows using Git
Distributed Developer Workflows using GitDistributed Developer Workflows using Git
Distributed Developer Workflows using Git
 
Git: be social
Git: be socialGit: be social
Git: be social
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git & gitflow
Git & gitflowGit & gitflow
Git & gitflow
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Git guide
Git guideGit guide
Git guide
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
 
Learning git
Learning gitLearning git
Learning 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
 
Fall18 Git presentation
Fall18 Git presentationFall18 Git presentation
Fall18 Git presentation
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
11 git version control
11 git version control11 git version control
11 git version control
 
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
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
 
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 

Version control

  • 1.
  • 2. Version Control Basics of Git References: http://gitref.org Feb. 23, 2013 http://git-scm.com
  • 3. Outline • What is Version Control • Why Version Control • Git as Version Control Tool Feb. 23, 2013
  • 5. What Version Control Feb. 23, 2013
  • 6. What Version Control lets you track your files Feb. 23, 2013
  • 7. What Version Control lets you track your files so when you mess up you can easily get back to a previous working version Feb. 23, 2013
  • 9. Why • Backup and Restore Feb. 23, 2013
  • 10. Why • Backup and Restore • Synchronization Feb. 23, 2013
  • 11. Why • Backup and Restore • Synchronization • Track Changes Feb. 23, 2013
  • 12. Why • Backup and Restore • Synchronization • Track Changes • Track Ownership Feb. 23, 2013
  • 13. How • Repository where files are being stored • Local Repository repository in the local machine • Remote Repository are versions of your project that are hosted over the Internet or network somewhere Feb. 23, 2013
  • 15. Git: Basics • Get / Create Repository Feb. 23, 2013
  • 16. Git: Basics • Get / Create Repository • Record Changes Feb. 23, 2013
  • 17. Git: Basics • Get / Create Repository • Record Changes • Track History Feb. 23, 2013
  • 18. Git: Basics • Get / Create Repository • Record Changes • Track History • Undo Things Feb. 23, 2013
  • 19. Git: Basics • Get / Create Repository • Record Changes • Track History • Undo Things • Sharing / Updating Files Feb. 23, 2013
  • 20. git-clone working staging remote local repo directory area repo git-add git-commit git-push git-reset git-fetch git-checkout git-pull git-diff git-diff --staged Feb. 23, 2013 Feb. 23, 2013
  • 21. Create / Get Feb. 23, 2013
  • 22. Create / Get • get remote repository Feb. 23, 2013
  • 23. Create / Get • get remote repository git clone [repository url] [destination] Feb. 23, 2013
  • 24. Create / Get • get remote repository git clone [repository url] [destination] • existing directory Feb. 23, 2013
  • 25. Create / Get • get remote repository git clone [repository url] [destination] • existing directory git init [path/to/directory|file] Feb. 23, 2013
  • 27. Record Changes • Tracked Files Feb. 23, 2013
  • 28. Record Changes • Tracked Files Files that are currently in the repository Feb. 23, 2013
  • 29. Record Changes • Tracked Files Files that are currently in the repository - unmodified, modified, staged Feb. 23, 2013
  • 30. Record Changes • Tracked Files Files that are currently in the repository - unmodified, modified, staged • Untracked Files Feb. 23, 2013
  • 31. Record Changes • Tracked Files Files that are currently in the repository - unmodified, modified, staged • Untracked Files Everything else Feb. 23, 2013
  • 33. Tracking New Files git add [path/to/file|directory] Feb. 23, 2013
  • 34. Tracking New Files git add [path/to/file|directory] git-add command adds files to the staging area Feb. 23, 2013
  • 36. Committing Staged Files git commit -m "message" Feb. 23, 2013
  • 37. Committing Staged Files git commit -m "message" git-commit command commits all staged files Feb. 23, 2013
  • 39. Ignoring Files • Blank lines or lines starting with # are ignored. Feb. 23, 2013
  • 40. Ignoring Files • Blank lines or lines starting with # are ignored. • Standard glob patterns work. Feb. 23, 2013
  • 41. Ignoring Files • Blank lines or lines starting with # are ignored. • Standard glob patterns work. • You can end patterns with a forward slash (/) to specify a directory. Feb. 23, 2013
  • 42. Ignoring Files • Blank lines or lines starting with # are ignored. • Standard glob patterns work. • You can end patterns with a forward slash (/) to specify a directory. •You can negate a pattern by starting it with an exclamation point (!). Feb. 23, 2013
  • 43. Staged and Unstaged Changes Feb. 23, 2013
  • 44. Staged and Unstaged Changes git diff Feb. 23, 2013
  • 45. Staged and Unstaged Changes git diff  shows diff of what is modified but unstaged Feb. 23, 2013
  • 46. Staged and Unstaged Changes git diff  shows diff of what is modified but unstaged git diff --staged Feb. 23, 2013
  • 47. Staged and Unstaged Changes git diff  shows diff of what is modified but unstaged git diff --staged shows the changes that will currently go into the next commit. Feb. 23, 2013
  • 48. Removing Files Renaming Files Tracking History Feb. 23, 2013
  • 49. Removing Files git rm [file/directory] Renaming Files Tracking History Feb. 23, 2013
  • 50. Removing Files git rm [file/directory] Renaming Files git mv current_file_name new_file_name Tracking History Feb. 23, 2013
  • 51. Removing Files git rm [file/directory] Renaming Files git mv current_file_name new_file_name Tracking History git log Feb. 23, 2013
  • 53. Undoing Things • Unstaging staged file Feb. 23, 2013
  • 54. Undoing Things • Unstaging staged file git reset HEAD <file> Feb. 23, 2013
  • 55. Undoing Things • Unstaging staged file git reset HEAD <file> • Unmodifying modified file Feb. 23, 2013
  • 56. Undoing Things • Unstaging staged file git reset HEAD <file> • Unmodifying modified file git checkout -- <file> Feb. 23, 2013
  • 57. Undoing Things • Unstaging staged file git reset HEAD <file> • Unmodifying modified file git checkout -- <file> These commands are actually suggested when running git-status command Feb. 23, 2013
  • 58. Sharing / Updating Files Feb. 23, 2013
  • 59. Sharing / Updating Files Remote Repositories Feb. 23, 2013
  • 60. Sharing / Updating Files Remote Repositories are versions of your project that are hosted over the Internet or network somewhere. Feb. 23, 2013
  • 61. Sharing / Updating Files Remote Repositories are versions of your project that are hosted over the Internet or network somewhere. • Show remote repository Feb. 23, 2013
  • 62. Sharing / Updating Files Remote Repositories are versions of your project that are hosted over the Internet or network somewhere. • Show remote repository • Add remote repository Feb. 23, 2013
  • 63. Sharing / Updating Files Remote Repositories are versions of your project that are hosted over the Internet or network somewhere. • Show remote repository • Add remote repository • Update/Sync remote repository Feb. 23, 2013
  • 64. Sharing / Updating Files Remote Repositories are versions of your project that are hosted over the Internet or network somewhere. • Show remote repository • Add remote repository • Update/Sync remote repository • Inspect remote repository Feb. 23, 2013
  • 66. Remote Repository • Show remote repository Feb. 23, 2013
  • 67. Remote Repository • Show remote repository git remote -v Feb. 23, 2013
  • 68. Remote Repository • Show remote repository git remote -v • Add remote repository Feb. 23, 2013
  • 69. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] Feb. 23, 2013
  • 70. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] • Update remote repository Feb. 23, 2013
  • 71. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] • Update remote repository git push [alias] [branch] Feb. 23, 2013
  • 72. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] • Update remote repository git push [alias] [branch] • Sync with remote Feb. 23, 2013
  • 73. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] • Update remote repository git push [alias] [branch] • Sync with remote git pull [alias] [branch] Feb. 23, 2013
  • 74. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] • Update remote repository git push [alias] [branch] • Sync with remote git pull [alias] [branch] • Inspect remote repository Feb. 23, 2013
  • 75. Remote Repository • Show remote repository git remote -v • Add remote repository git remote add [alias] [repository url] • Update remote repository git push [alias] [branch] • Sync with remote git pull [alias] [branch] • Inspect remote repository git remote show [alias] Feb. 23, 2013