SlideShare ist ein Scribd-Unternehmen logo
1 von 42
git
git
get git on board
git?


• Version control system
git?


• Version control system
• Designed and developed by Linus Torvalds
  for Linux kernel development
git?

• Version control system
• Designed and developed by Linus Torvalds
  for Linux kernel development
• Like Subversion, but better...
git?

• Version control system
• Designed and developed by Linus Torvalds
  for Linux kernel development
• Like Subversion, but better...
• How???
git > svn
git > svn
git > svn

• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i.e. `git clone ...` vs `svn checkout ...`)
git > svn

• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i.e. `git clone ...` vs `svn checkout ...`)
  • You can commit/branch/merge locally.
    Read: Fast & offline.
git > svn
• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i.e. `git clone ...` vs `svn checkout ...`)
  • You can commit/branch/merge locally.
    Read: Fast & offline.
  • No single point of failure.
git > svn
• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i.e. `git clone ...` vs `svn checkout ...`)
  • You can commit/branch/merge locally.
    Read: Fast & offline.
  • No single point of failure.
  • No “latest revision”: unique revision ID
git > svn


• Lightweight Branching
 • Branch and merge often (per feature?)
git > svn

• Lightweight Branching
 • Branch and merge often (per feature?)
 • Intelligent 3-way merging = rarely manual
git > svn

• Lightweight Branching
 • Branch and merge often (per feature?)
 • Intelligent 3-way merging = rarely manual
git > svn


• Small Space Requirements
 • Ex: Mozilla: SVN:12GB => git:420MB
git > svn


• git submodules vs svn externals
 • Not covered in this presentation
A couple new concepts

• “Remote” or “upstream”: A remotely
  accessible repository.
 • Push to a remote
 • Pull from a remote
A couple new concepts
• “Staging area” or “index”: What will go into
  your next commit.
  • Example:
    • mate new_file.rb <= not staged
    • git add new_file.rb <= staged
    • git commit -a -m “Added a new file.”
      • Staging area is now empty.
Everything clear?
Get Started
Get Git Started
Get Git Started


• Yes, I know it’s getting gitting old
Get Git Started

•   Install on OSX

    •   git-osx-installer - Recommended.

    •   OR

    •   sudo port install git-core +svn +doc +bash_completion +gitweb
Get Git Started

• Configure your user
 • git config --global user.name "Bobby SV"
 • git config --global user.email
    "bob@sv.com"
git commands: basics
  git init                           Initialize a git repository.

 git add                            Add files to a repository.

  git diff                                Generate a diff.

git status             Show uncommitted changes to the current project.

  git rm                         Remove a file from a repository.

  git mv                         Moves a file within a repository.

git commit   Commits staged changes. Use ‘-a’ to automatically stage every file that is
                           already tracked before doing the commit.
  git log                             View a log of commits.

git blame         Show what revision and author last modified each line of a file.

 git show       View the contents of a file, the listing of a directory or a commit.
git commands: branches
 git tag -a name                      Add a tag with the indicated name.

     git tag -l                                    List tags.

  git push --tags                            Push tags to remote.

 git branch name                   Create a branch with the indicated name.

git checkout name                       Switches to the branch ‘name’.

  git branch -a                List branches (current branch indicated with ‘*’).

 git merge name           Merge changes from branch name into the current branch.

git cherry-pick rev   Apply the changes in revision rev and commit to the current branch.

git branch -d name                        Deletes the named branch.
git commands: remote
        git clone url          Clone a repository. Sets up master branch w/ origin remote.


          git fetch                      Fetch updates from a remote repository.


          git pull             git fetch + git merge - Use this more often than either alone.


        git remote                                     List remotes.


git push remote local_branch   Push changes to remote. (remote & local_branch are optional)


    git remote add url                Add a remote branch to the repository at url.


 git remote show remote               Shows the branches in the remote repository.
git commands: advanced
git checkout --track -b branch origin/
                                            Create a corresponding local branch which will "track" the remote branch
                branch

              git stash                                 Store uncommitted changes and reverts to HEAD.

              git rebase                 Provides fine-grained control of commits. Allows you to take all the changes that
                                                were committed on one branch and replay them on another one.
              git revert                  Undo a previous commit. Very different from `svn revert file` (which would be
                                                    done with `git checkout file`or `git reset --hard HEAD`)
          git format-patch                                    Prepare a patch for other developers.

               git fsck                                                 Check for errors.

            git gc --prune                                             Cleanup repository.

           git grep “foo()”                                    Search working directory for foo().

     git merge --squash branch                              Represent many commits as one commit.

          git whatchanged                                    Show the differences between commits.

         git show HEAD~4                     HEAD~4 is short for HEAD^^^^. Each ‘^’ represents a parent revision.
overwhelmed?
git workflowz
Flow #1: simple/local
• cd project_cornice
• git init
• Set up your ignores (next slide)
• git add .
• git commit -a -m "Initial import."
• mate file.rb (make changes)
• git commit -a -m "Make file better."
Flow #1: simple/local
• More on .gitignore files
 • Like SVN’s `svn propset ignore`
 • For example, in project root,
    add .gitignore containing:
   • log/*.log
   • tmp/**/*
Flow #2: local with
            branches
(master)$ git branch test_branch
(master)$ git checkout test_branch
Switched to branch "test_branch"
(test_branch)$ mate README
(test_branch)$ git commit -a -m "Improved file significantly."
[test_branch 6bba901] Improved file significantly.
 1 files changed, 1 insertions(+), 0 deletions(-)
(test_branch)$ git checkout master
Switched to branch "master"
(master)$ git merge test_branch
Updating 197ab8c..6bba901
Fast forward
 README | 1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Flow #3: remotes

•   git clone git@github.com:rangsikitpho/cornice.git

•   cd cornice

•   mate new_file.rb

•   git add new_file.rb

•   git commit -a -m “Did something amazing.”

•   git push [origin] [master]
Flow #4: full cycle
 •   git clone git@github.com:rangsikitpho/cornice.git

 •   cd cornice

 •   git checkout -b feature_branch

 •   mate new_file.rb

 •   git add new_file.rb

 •   git commit -a -m “Did something amazing.”

 •   git checkout master

 •   git merge feature_branch

 •   git push [origin] [master]

 •   git pull [origin] [master]
Flow #4: full cycle
            •   git clone git@github.com:rangsikitpho/cornice.git

            •   cd cornice

            •   git checkout -b feature_branch

            •   mate new_file.rb

Virtuous    •   git add new_file.rb
 Cycle
            •   git commit -a -m “Did something amazing.”

            •   git checkout master

            •   git merge feature_branch

            •   git push [origin] [master]

            •   git pull [origin] [master]
Bonus!!!
•   Have dropbox? (http://dropbox.com)
    •   Use it as a remote!
•   How?
    •   Main computer, from existing repository:

        •   $ git clone --bare . ~/Dropbox/code/repo.git

        •   $ git remote add dropbox ~/Dropbox/code/repo.git

        •   $ git push dropbox master

    •   Another computer:

        •   $ git clone ~/Dropbox/code/repo.git

        •   $ git remote add dropbox ~/Dropbox/code/repo.git

        •   $ git pull dropbox master
Refs
•   git-osx-installer:

    •    http://code.google.com/p/git-osx-installer/

•   git branch info on command prompt

    •    e.g. [bob:~/code/cornice(master)]$

    •    http://gist.github.com/283341

•   OSX GUI

    •    gitnub: http://wiki.github.com/Caged/gitnub/

    •    gitx: http://gitx.frim.nl/

•   git textmate bundle

    •    http://github.com/jcf/git-tmbundle

•   git tutorial

    •    http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html

    •    http://progit.org/book/ch3-6.html (In depth explanation of ‘git rebase’)

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
git and github
git and githubgit and github
git and github
 
From svn to git
From svn to gitFrom svn to git
From svn to git
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Git
GitGit
Git
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git basic
Git basicGit basic
Git basic
 
Git As A Subversion Replacement
Git As A Subversion ReplacementGit As A Subversion Replacement
Git As A Subversion Replacement
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 

Andere mochten auch

Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started PresentationNap Ramirez
 
Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Arnaud Boudou
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
raspberry pi
 raspberry pi raspberry pi
raspberry piTECOS
 
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
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 

Andere mochten auch (13)

Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 
From SVN to Git
From SVN to GitFrom SVN to Git
From SVN to Git
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Intro To Git
Intro To GitIntro To Git
Intro To Git
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
 
raspberry pi
 raspberry pi raspberry pi
raspberry pi
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to 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
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Raspberry-Pi
Raspberry-PiRaspberry-Pi
Raspberry-Pi
 

Ähnlich wie How to Get Started with Git Version Control

Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.comdropsolid
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Brian K. Vagnini
 

Ähnlich wie How to Get Started with Git Version Control (20)

390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Git
GitGit
Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Session git
Session gitSession git
Session git
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git basics
Git basicsGit basics
Git basics
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git
GitGit
Git
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 

Kürzlich hochgeladen

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
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
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 

Kürzlich hochgeladen (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
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...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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...
 
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
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 

How to Get Started with Git Version Control

  • 1. git
  • 3.
  • 5. git? • Version control system • Designed and developed by Linus Torvalds for Linux kernel development
  • 6. git? • Version control system • Designed and developed by Linus Torvalds for Linux kernel development • Like Subversion, but better...
  • 7. git? • Version control system • Designed and developed by Linus Torvalds for Linux kernel development • Like Subversion, but better... • How???
  • 10. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`)
  • 11. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`) • You can commit/branch/merge locally. Read: Fast & offline.
  • 12. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`) • You can commit/branch/merge locally. Read: Fast & offline. • No single point of failure.
  • 13. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`) • You can commit/branch/merge locally. Read: Fast & offline. • No single point of failure. • No “latest revision”: unique revision ID
  • 14. git > svn • Lightweight Branching • Branch and merge often (per feature?)
  • 15. git > svn • Lightweight Branching • Branch and merge often (per feature?) • Intelligent 3-way merging = rarely manual
  • 16. git > svn • Lightweight Branching • Branch and merge often (per feature?) • Intelligent 3-way merging = rarely manual
  • 17. git > svn • Small Space Requirements • Ex: Mozilla: SVN:12GB => git:420MB
  • 18. git > svn • git submodules vs svn externals • Not covered in this presentation
  • 19. A couple new concepts • “Remote” or “upstream”: A remotely accessible repository. • Push to a remote • Pull from a remote
  • 20. A couple new concepts • “Staging area” or “index”: What will go into your next commit. • Example: • mate new_file.rb <= not staged • git add new_file.rb <= staged • git commit -a -m “Added a new file.” • Staging area is now empty.
  • 24. Get Git Started • Yes, I know it’s getting gitting old
  • 25. Get Git Started • Install on OSX • git-osx-installer - Recommended. • OR • sudo port install git-core +svn +doc +bash_completion +gitweb
  • 26. Get Git Started • Configure your user • git config --global user.name "Bobby SV" • git config --global user.email "bob@sv.com"
  • 27. git commands: basics git init Initialize a git repository. git add Add files to a repository. git diff Generate a diff. git status Show uncommitted changes to the current project. git rm Remove a file from a repository. git mv Moves a file within a repository. git commit Commits staged changes. Use ‘-a’ to automatically stage every file that is already tracked before doing the commit. git log View a log of commits. git blame Show what revision and author last modified each line of a file. git show View the contents of a file, the listing of a directory or a commit.
  • 28. git commands: branches git tag -a name Add a tag with the indicated name. git tag -l List tags. git push --tags Push tags to remote. git branch name Create a branch with the indicated name. git checkout name Switches to the branch ‘name’. git branch -a List branches (current branch indicated with ‘*’). git merge name Merge changes from branch name into the current branch. git cherry-pick rev Apply the changes in revision rev and commit to the current branch. git branch -d name Deletes the named branch.
  • 29. git commands: remote git clone url Clone a repository. Sets up master branch w/ origin remote. git fetch Fetch updates from a remote repository. git pull git fetch + git merge - Use this more often than either alone. git remote List remotes. git push remote local_branch Push changes to remote. (remote & local_branch are optional) git remote add url Add a remote branch to the repository at url. git remote show remote Shows the branches in the remote repository.
  • 30. git commands: advanced git checkout --track -b branch origin/ Create a corresponding local branch which will "track" the remote branch branch git stash Store uncommitted changes and reverts to HEAD. git rebase Provides fine-grained control of commits. Allows you to take all the changes that were committed on one branch and replay them on another one. git revert Undo a previous commit. Very different from `svn revert file` (which would be done with `git checkout file`or `git reset --hard HEAD`) git format-patch Prepare a patch for other developers. git fsck Check for errors. git gc --prune Cleanup repository. git grep “foo()” Search working directory for foo(). git merge --squash branch Represent many commits as one commit. git whatchanged Show the differences between commits. git show HEAD~4 HEAD~4 is short for HEAD^^^^. Each ‘^’ represents a parent revision.
  • 33. Flow #1: simple/local • cd project_cornice • git init • Set up your ignores (next slide) • git add . • git commit -a -m "Initial import." • mate file.rb (make changes) • git commit -a -m "Make file better."
  • 34. Flow #1: simple/local • More on .gitignore files • Like SVN’s `svn propset ignore` • For example, in project root, add .gitignore containing: • log/*.log • tmp/**/*
  • 35. Flow #2: local with branches (master)$ git branch test_branch (master)$ git checkout test_branch Switched to branch "test_branch" (test_branch)$ mate README (test_branch)$ git commit -a -m "Improved file significantly." [test_branch 6bba901] Improved file significantly. 1 files changed, 1 insertions(+), 0 deletions(-) (test_branch)$ git checkout master Switched to branch "master" (master)$ git merge test_branch Updating 197ab8c..6bba901 Fast forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 36. Flow #3: remotes • git clone git@github.com:rangsikitpho/cornice.git • cd cornice • mate new_file.rb • git add new_file.rb • git commit -a -m “Did something amazing.” • git push [origin] [master]
  • 37. Flow #4: full cycle • git clone git@github.com:rangsikitpho/cornice.git • cd cornice • git checkout -b feature_branch • mate new_file.rb • git add new_file.rb • git commit -a -m “Did something amazing.” • git checkout master • git merge feature_branch • git push [origin] [master] • git pull [origin] [master]
  • 38. Flow #4: full cycle • git clone git@github.com:rangsikitpho/cornice.git • cd cornice • git checkout -b feature_branch • mate new_file.rb Virtuous • git add new_file.rb Cycle • git commit -a -m “Did something amazing.” • git checkout master • git merge feature_branch • git push [origin] [master] • git pull [origin] [master]
  • 39.
  • 40. Bonus!!! • Have dropbox? (http://dropbox.com) • Use it as a remote! • How? • Main computer, from existing repository: • $ git clone --bare . ~/Dropbox/code/repo.git • $ git remote add dropbox ~/Dropbox/code/repo.git • $ git push dropbox master • Another computer: • $ git clone ~/Dropbox/code/repo.git • $ git remote add dropbox ~/Dropbox/code/repo.git • $ git pull dropbox master
  • 41.
  • 42. Refs • git-osx-installer: • http://code.google.com/p/git-osx-installer/ • git branch info on command prompt • e.g. [bob:~/code/cornice(master)]$ • http://gist.github.com/283341 • OSX GUI • gitnub: http://wiki.github.com/Caged/gitnub/ • gitx: http://gitx.frim.nl/ • git textmate bundle • http://github.com/jcf/git-tmbundle • git tutorial • http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html • http://progit.org/book/ch3-6.html (In depth explanation of ‘git rebase’)