SlideShare une entreprise Scribd logo
1  sur  37
GIT Introduction




  Vu Viet Phuong - PortalTeam
Objective


 
       Understand the advantage of GIT and
       determine if we should use GIT or not.


  
      Know how to use the common used GIT commands




                                2
Subject

  
      Characteristic of GIT
      – The most powerful features of GIT
      – Explain the differences between GIT and SVN

  • GIT basic usages
      - Day to day GIT used commands


  • Tips and Tricks



                                  3
Characteristic of GIT

                        4
History


 
     Invented by Linus Torvalds to
         support the development of the Linux Kernel



     Incredibly fast, very effi cient with large projects,
      has an incredible branching system for non-linear development


 
     Projects using Git : Linux Kernel, Perl, Eclipse, Android ...




                                      5
Compare to SVN


    There are many version control tools in the market
       But GIT is a completely difference tool
       GIT own many distinct, powerful features



    Interface is fairly similar to SVN



    Git stores and thinks about data differently than SVN




                                    6
SVN Data Model

SVN store history as a list of file-based changes




                         7
GIT Data Model




Database addressable by the hash value of its contents
                          8
Repository

 
     GIT - Local and multi Remote Repositories
         SVN – only 1 repository on server

 
     SVN may loose history in some case, Git doesn't




                                   9
Why's GIT fast ?

  
          The internal database structure


  
          Nearly every operation is Local
                 Entire history is on local disk


      
          This database is compressed effectively
           transfer over network, use SSH or GIT protocol



                                       10
State

 
     States : untracked, modified, and staged, committed




                                  11
Working Area

 
     The Git directory, the working directory, and the staging area.




                                    12
Branch Management

  
      Killer feature – Managing branches
          Make Git apart in the VCS community


  
      Branching operations nearly instantaneous
         Switching back and forth between branches just as fast


  
      We can create branches, and merge often
         even multiple times in a day


                               13
Switch Branch

                Point to current Branch




                              Switch branch


                         14
FastForward Merge




  Merge testing to master
                                 Move pointer forward




                            15
FastForward Push

  
      GIT “push” comand equals to svn commit
         By default, GIT only allow “FastForward” push
         To override this, use --force option
                                             before push




                                             public repository's master
                                                  after force push




                               16
Modify History

  
      Return to one point in History
         $ git reset --hard <commitID>


  
      Replace last commit
         $ git commit –amend -m <msg>


  
      Rebase history
         $ git rebase -i <commitID>



                               17
Working with Patch

  
      Support binary patch
       Resize a “jpeg” file → support create patch
         $ git diff --binary > patchToFile


  
      Create – apply mutiple patches


  
      Cherry picking



                               18
Git Basics

             19
Installing GIT

                   http://git-scm.com/download


    Window, Mac – Download Installation file



    Linux - The primary Git package :
       git-core, git-doc – document
       git-cvs, git-svn – work with CVS, or SVN
       gitk           – graphical application



     $ sudo apt-get install git-core git-doc gitk git-svn

                                         20
Configuration

     
         3 Config files:
              /etc/gitconfig     → all users, repositories (--system)
              ~/.gitconfig       → one user, all repo       (--global)
              [repo]/.git/config → specific to repository (default)

 
         Your Identity – information in each commit
             $ git config --global user.name "phuong_vu"
             $ git config --global user.email
              phuong_vu@exoplatform.com
 
         List all config values:
            $ git config --list


                                      21
Ignoring Files

 
     3 places to put ignore file names:
      .gitignore
            specific to folder, go with source code to public repo

      .git/info/exclude
              not share with others

      $ git config core.excludesfile <path>
              can use system, global, or default config file


                                22
Create .git

 
     Initialized empty Git repository (.git folder)
          $ git init


 
     Cloning an existing Repository
         $ git clone <url>


 
     Create GIT repo from SVN repo
         $ git svn clone --username <name> <url>


                                 23
Everyday works
                      $ git add [-A] [-i] <path>
                         add changes to index



                      $ git reset --hard
                         remove changes


                      $ git commit [-a] -m “msg”
                         commit changes



                 24
View Changes

 
     Git store project snapshot on each commit
          SVN store a list of file-based changes
                $ git show <commitID>

 
     Uncommitted changes
               $ git diff [--cached]

 
     Changes between branches
               $ git diff master..standalone


                                  25
View History

           $ git log [--pretty] [--graph] [--grep] [-S]
 --pretty → display format
 --graph → show history in diagram
 --grep   → search by commit msg
 --S      → search by diff


 
     Search log by content
               $ git log --follow [PATH]


                                26
Revert Changes
 
     Modify history
        Replace last commit
             $ git commit --amend -m “msg”
        Reset your history
             $ git reset --hard <commitID>
        Rebase history


 
     Make new commit
             $ git revert <commitID>


                              27
Share Changes
 
     Remote Repository
        Versions of your project hosted on some where else

 
     Show remotes
              $ git remote [show <remoteName>]

 
     Push – Pull changes (svn commit | update)
              $ git [push | pull] [remoteName]




                                 28
Local and Remote

 
     GIT have 2 types of branch : local, remote branch


 
     Local branch
        $ git branch <name>           #create branch
        $ git checkout <name>         #switch to
        $ git branch -d <name>        #delete


 
     Remote branch : local branches that can't be switched to
        Act like a cache of remote repository's branch


                                 29
Remote Branch

 
     Show remote branches
        $ git branch -r

 
     Make your history simple
        $ git fetch [remote]
        $ git rebase [remote/branch]


 
     Remote tracking branch
        $ git checkout -b <name> <remote/branch>



                                30
Patch

 
     Create – apply multi patches
        $ git format-patch <commitID>
        $ git am <path>

 
     Cherry picking
        $ git cherry-pick <commitID>


 
     Stashing – temporary save your work
        $ git stash [apply]



                               31
Tips and Tricks
Auto-Completion

  
      Git source:
        contrib/completion/git-completion.bash


       $ git chec → [TAB] → $ git checkout


                                               Copy to folder
 Ubuntu    /etc/bash_completion.d/
 Mac       /opt/local/etc/bash_completion.d/


                               33
Alias

 
     Make commands shorter
     Create alias for long and common use commands



$ git config --global alias.lg "log --pretty=oneline --graph"
                     now use $ git lg




                               34
Editor


 
     GIT default uses system's default editor
         configure the text editor if we don't like the default one


      $ git config --global core.editor gedit
                        or
         $ export GIT_EDITOR=gedit




                                 35
Diff Tool

 
     Git has an internal implementation of diff
     But we can set up external merge and diff tools


 
     Git accepts xxdiff, emerge, vimdiff, gvimdiff, opendiff...


          $ git config --global merge.tool vimdiff




                                  36
Resources


 http://whygitisbetterthanx.com
     More explaination why use GIT



      Basic tutorial

      Version Control with Git - O'Reilly Media
                 Advance GIT

                        37

Contenu connexe

Tendances

Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control SystemKMS Technology
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamentalRajesh Kumar
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control SystemMohammad Imam Hossain
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...Edureka!
 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial IIJim Yeh
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 

Tendances (20)

Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git101
Git101Git101
Git101
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Bitbucket
BitbucketBitbucket
Bitbucket
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Github basics
Github basicsGithub basics
Github basics
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
git and github
git and githubgit and github
git and github
 
Git and Github
Git and GithubGit and Github
Git and Github
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 

En vedette

Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideRohit Arora
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlowMark Everard
 
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Per Henrik Lausten
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHubNishan Bose
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHubThibault Vlacich
 
GitHub - Présentation
GitHub - PrésentationGitHub - Présentation
GitHub - PrésentationDavid RIEHL
 
Git pour les (pas si) nuls
Git pour les (pas si) nulsGit pour les (pas si) nuls
Git pour les (pas si) nulsMalk Zameth
 

En vedette (13)

Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guide
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlow
 
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHub
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHub
 
GitHub - Présentation
GitHub - PrésentationGitHub - Présentation
GitHub - Présentation
 
Git pour les (pas si) nuls
Git pour les (pas si) nulsGit pour les (pas si) nuls
Git pour les (pas si) nuls
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 

Similaire à Git training

Similaire à Git training (20)

Git
GitGit
Git
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and github
Git and githubGit and github
Git and github
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anyways
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control System
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheets
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git
GitGit
Git
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git 101 for_tarad_dev
Git 101 for_tarad_devGit 101 for_tarad_dev
Git 101 for_tarad_dev
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Advanted git
Advanted git Advanted git
Advanted git
 
Brown bag sessions git workshop
Brown bag sessions git workshopBrown bag sessions git workshop
Brown bag sessions git workshop
 
Git training v10
Git training v10Git training v10
Git training v10
 

Plus de adm_exoplatform

Plus de adm_exoplatform (14)

Magento
MagentoMagento
Magento
 
E xo mobile_overview_best_practice_in_mobile_application_design
E xo mobile_overview_best_practice_in_mobile_application_designE xo mobile_overview_best_practice_in_mobile_application_design
E xo mobile_overview_best_practice_in_mobile_application_design
 
Advance jquery-plugin
Advance jquery-pluginAdvance jquery-plugin
Advance jquery-plugin
 
Development withforce
Development withforceDevelopment withforce
Development withforce
 
Hadoop
HadoopHadoop
Hadoop
 
Jquery ui
Jquery uiJquery ui
Jquery ui
 
Cmsms
CmsmsCmsms
Cmsms
 
Jquery
JqueryJquery
Jquery
 
Java application server in the cloud
Java application server in the cloudJava application server in the cloud
Java application server in the cloud
 
I os
I osI os
I os
 
Memory and runtime analysis
Memory and runtime analysisMemory and runtime analysis
Memory and runtime analysis
 
Jvm mbeans jmxtran
Jvm mbeans jmxtranJvm mbeans jmxtran
Jvm mbeans jmxtran
 
Cluster mode and plf cluster
Cluster mode and plf clusterCluster mode and plf cluster
Cluster mode and plf cluster
 
Cluster mode and plf cluster
Cluster mode and plf clusterCluster mode and plf cluster
Cluster mode and plf cluster
 

Dernier

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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 DevelopmentsTrustArc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
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
 
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...Igalia
 
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 2024Rafal Los
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
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
 
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
 
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 Scriptwesley chun
 
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
 
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.pptxHampshireHUG
 
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 MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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 RobisonAnna Loughnan Colquhoun
 

Dernier (20)

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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
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
 
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...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
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
 
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...
 
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
 
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
 
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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 

Git training

  • 1. GIT Introduction Vu Viet Phuong - PortalTeam
  • 2. Objective  Understand the advantage of GIT and determine if we should use GIT or not.  Know how to use the common used GIT commands 2
  • 3. Subject  Characteristic of GIT – The most powerful features of GIT – Explain the differences between GIT and SVN • GIT basic usages - Day to day GIT used commands • Tips and Tricks 3
  • 5. History  Invented by Linus Torvalds to support the development of the Linux Kernel  Incredibly fast, very effi cient with large projects, has an incredible branching system for non-linear development  Projects using Git : Linux Kernel, Perl, Eclipse, Android ... 5
  • 6. Compare to SVN  There are many version control tools in the market But GIT is a completely difference tool GIT own many distinct, powerful features  Interface is fairly similar to SVN  Git stores and thinks about data differently than SVN 6
  • 7. SVN Data Model SVN store history as a list of file-based changes 7
  • 8. GIT Data Model Database addressable by the hash value of its contents 8
  • 9. Repository  GIT - Local and multi Remote Repositories SVN – only 1 repository on server  SVN may loose history in some case, Git doesn't 9
  • 10. Why's GIT fast ?  The internal database structure  Nearly every operation is Local Entire history is on local disk  This database is compressed effectively transfer over network, use SSH or GIT protocol 10
  • 11. State  States : untracked, modified, and staged, committed 11
  • 12. Working Area  The Git directory, the working directory, and the staging area. 12
  • 13. Branch Management  Killer feature – Managing branches Make Git apart in the VCS community  Branching operations nearly instantaneous Switching back and forth between branches just as fast  We can create branches, and merge often even multiple times in a day 13
  • 14. Switch Branch Point to current Branch Switch branch 14
  • 15. FastForward Merge Merge testing to master Move pointer forward 15
  • 16. FastForward Push  GIT “push” comand equals to svn commit By default, GIT only allow “FastForward” push To override this, use --force option before push public repository's master after force push 16
  • 17. Modify History  Return to one point in History $ git reset --hard <commitID>  Replace last commit $ git commit –amend -m <msg>  Rebase history $ git rebase -i <commitID> 17
  • 18. Working with Patch  Support binary patch Resize a “jpeg” file → support create patch $ git diff --binary > patchToFile  Create – apply mutiple patches  Cherry picking 18
  • 20. Installing GIT http://git-scm.com/download  Window, Mac – Download Installation file  Linux - The primary Git package : git-core, git-doc – document git-cvs, git-svn – work with CVS, or SVN gitk – graphical application $ sudo apt-get install git-core git-doc gitk git-svn 20
  • 21. Configuration  3 Config files: /etc/gitconfig → all users, repositories (--system) ~/.gitconfig → one user, all repo (--global) [repo]/.git/config → specific to repository (default)  Your Identity – information in each commit $ git config --global user.name "phuong_vu" $ git config --global user.email phuong_vu@exoplatform.com  List all config values: $ git config --list 21
  • 22. Ignoring Files  3 places to put ignore file names: .gitignore specific to folder, go with source code to public repo .git/info/exclude not share with others $ git config core.excludesfile <path> can use system, global, or default config file 22
  • 23. Create .git  Initialized empty Git repository (.git folder) $ git init  Cloning an existing Repository $ git clone <url>  Create GIT repo from SVN repo $ git svn clone --username <name> <url> 23
  • 24. Everyday works $ git add [-A] [-i] <path> add changes to index $ git reset --hard remove changes $ git commit [-a] -m “msg” commit changes 24
  • 25. View Changes  Git store project snapshot on each commit SVN store a list of file-based changes $ git show <commitID>  Uncommitted changes $ git diff [--cached]  Changes between branches $ git diff master..standalone 25
  • 26. View History $ git log [--pretty] [--graph] [--grep] [-S] --pretty → display format --graph → show history in diagram --grep → search by commit msg --S → search by diff  Search log by content $ git log --follow [PATH] 26
  • 27. Revert Changes  Modify history Replace last commit $ git commit --amend -m “msg” Reset your history $ git reset --hard <commitID> Rebase history  Make new commit $ git revert <commitID> 27
  • 28. Share Changes  Remote Repository Versions of your project hosted on some where else  Show remotes $ git remote [show <remoteName>]  Push – Pull changes (svn commit | update) $ git [push | pull] [remoteName] 28
  • 29. Local and Remote  GIT have 2 types of branch : local, remote branch  Local branch $ git branch <name> #create branch $ git checkout <name> #switch to $ git branch -d <name> #delete  Remote branch : local branches that can't be switched to Act like a cache of remote repository's branch 29
  • 30. Remote Branch  Show remote branches $ git branch -r  Make your history simple $ git fetch [remote] $ git rebase [remote/branch]  Remote tracking branch $ git checkout -b <name> <remote/branch> 30
  • 31. Patch  Create – apply multi patches $ git format-patch <commitID> $ git am <path>  Cherry picking $ git cherry-pick <commitID>  Stashing – temporary save your work $ git stash [apply] 31
  • 33. Auto-Completion  Git source: contrib/completion/git-completion.bash $ git chec → [TAB] → $ git checkout Copy to folder Ubuntu /etc/bash_completion.d/ Mac /opt/local/etc/bash_completion.d/ 33
  • 34. Alias  Make commands shorter Create alias for long and common use commands $ git config --global alias.lg "log --pretty=oneline --graph" now use $ git lg 34
  • 35. Editor  GIT default uses system's default editor configure the text editor if we don't like the default one $ git config --global core.editor gedit or $ export GIT_EDITOR=gedit 35
  • 36. Diff Tool  Git has an internal implementation of diff But we can set up external merge and diff tools  Git accepts xxdiff, emerge, vimdiff, gvimdiff, opendiff... $ git config --global merge.tool vimdiff 36
  • 37. Resources http://whygitisbetterthanx.com More explaination why use GIT Basic tutorial Version Control with Git - O'Reilly Media Advance GIT 37