SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Getting Started with Git
5/17/2012




                             This presentation is at:

                             http://sn.im/startgit

                             If you're on Google Docs, make sure to read the
                             'speaker notes' for this presentation.




Rick Umali
rickumali@gmail.com
http://tech.rickumali.com/
Questions I Plan to Answer
What is source control?

What is the big deal with Git?

Can you show me a little Git?
  Commits. Branches. Merges. Remote repos.
What is Source Control?
A mechanism to track changes in source code.

Used for version history, auditing, and
recovery.

Source code control is the most important
practice a coding professional can do.
Revision Control Example: Wiki
Revision Control Example: Git
This is what we'll be trying.
Git
Git is an open source, distributed version
control system designed for speed and
efficiency.

                    ● Freedom
             ●   No "server" required
             ●   Unique architecture
Installing Git
 http://git-scm.com/book/en/Getting-Started-Installing-Git

           The installation is very easy!
Warning: Command Line Ahead
First Time Use: Set Up
Tell Git who you are!

% git config --global user.name "Rick Umali"
% git config --global user.email "rickumali@gmail.com"


Future 'commits' will show this information.
% git config --list


See "git config --help" for more configurations.
Creating a "Repository"
Let's pretend we're developing a Drupal
module.

%   cd web/sites/all/modules
%   mkdir dumpstamp
%   cd dumpstamp
%   git init

"git init" creates the entire Git repository. No
server interaction required!
Committing Your First File
To 'commit' means 'to save the state' of your
work. You must first 'add' this change to the
'staging area'.

% vi README.txt
% git add README.txt
% git commit -m "First commit. README file."


Use 'git help' to learn all the switches. -m
stands for message.
Looking at the Repository
% git log

Each 'commit' contains an ID, along with the
author information from earlier, and a time
stamp.

% gitk

GUI tools can help you visualize the 'repo.'
Adding More Files
%   vi dumpstamp.info dumpstamp.module
%   git status
%   git add .
%   git commit

This second commit saves the work of adding
two files by using 'git add .'.

The .module and .info files are the two required
files for every Drupal module.
Bonus: Creating a Module
% drush pm-info dumpstamp
% drush enable dumpstamp
Examining Changes to Files
%   vi dumpstamp.module
%   git status
%   git diff
%   git add dumpstamp.module
%   git commit
%   git log


The above is a typical 'workflow'.

Git offers suggestions and hints as you use
it.
Doing More Changes
% vi dumpstamp.module
% git diff
% git commit -a

Or even:

% git commit -a -m "Commit message."


Another typical 'workflow'.
Looking at the Log Again
The history can be examined different ways.

%   git   log
%   git   log --format=short
%   git   log --format=oneline
%   git   log --oneline
Revisiting History
You can 'revisit' any point of your history.

% git checkout SHAID

Every commit is known by its SHA ID.

This is the first step in making a branch! (Use
git checkout master to revert.)
Branching and Merging Next, But...
What we have covered so far is probably 70-
    80% of what you will do with git.

Adding and committing files are the heart of
  git (and any version control system).
Branching
Git encourages experimentation, by making
branching very easy.
Branching: git checkout -b
% git checkout -b BRANCH SHA1

Make some edits on a change below the
master, then commit.

git branch makes a branch from the branch
you're on (default branch is 'master').
Branching: Starting State

NOTE: 'master' is a branch that's created 'by default'.




                    master        SHA 1A
Branching: Make Some Changes
git commit



             master   SHA 2B




                      SHA 1A
Branching: Making a Branch
git checkout -b branch1 SHA1



    master        SHA 2B




                  SHA 1A           branch1




         NOTE: This command is a short cut for: git branch branch1 name_of_branch ,
         then git checkout branch1 .
Branching: Changes on the Branch
(Make changes in branch1.)
git commit


 master    SHA 2B        SHA 3C   branch1




                SHA 1A
Visualizing the Branches
Merging
Bringing two branches together.

Git calculates the correct 'merge base'.

First 'checkout' the branch you want to merge
into (typically master), then 'merge' the branch.

% git checkout master
% git merge BRANCH
Merging: Starting State
git branch




master   SHA 2B        SHA 3C   branch1




              SHA 1A
Merging: Two Steps
git checkout master
git merge branch1


     master            SHA 4D




              SHA 2B            SHA 3C   branch1




                   SHA 1A
Merging: The Hard Part
Manual 'merging' may be required.
Visualizing the Merge
Whew!
Remote Branches
You can 'browse' public Git repositories for
code that you want to examine or use.

You can upload a local Git repository to a
public Git repository.
Common Public Git Repositories
Browsing and Grabbing Code




git clone git@github.com:rickumali/RickUmaliVanityWebsite.
git
Uploading Code (to Github)
Create a key pair on your machine.

Create a repository (on Github).

Add a 'remote' (via git remote add).

Upload your code (via git push).
Creating a Key Pair
Creating a Repository
Adding a Remote, then Upload
After An Upload (to Github)




git clone git@github.com:rickumali/DumpStamp.git
Next Steps
Install Git.

Commit your code changes frequently.

Log verbosely (in commit messages).

Experiment (branch) often.
Resources
http://git-scm.org/
    Both "Pro Git" book, and Git reference
http://gitref.org/
    A "quicker" Git reference
http://www-cs-students.stanford.edu/~blynn/gitmagic/
    "Friendlier" Git walk-through (git magic).
http://drupal.org/node/803746
    A workflow for using Git with Drupal.
http://www.mail-archive.com/dri-devel@lists.sourceforge.
net/msg39091.html
    Linus on "clean history."
Resources
http://www.youtube.com/watch?v=4XpnKHJAok8
    Linus Torvalds (Git creator) (May '07)
http://www.youtube.com/watch?v=8dhZ9BXQgc4
    Randal Schwartz (Perl expert and Git old-timer) (Oct
'07)
http://www.youtube.com/watch?v=ZDR433b0HJY
    Scott Chacon (Pro Git author) (July '11)
Getting Started with Git

                       Thank you!




Rick Umali
rickumali@gmail.com
http://tech.rickumali.com/

Weitere ähnliche Inhalte

Was ist angesagt?

Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - GitCarlo Bernaschina
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierChristoph Matthies
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsMikhail Melnik
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-BryanLearningTech
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitJason Byrne
 
Stable master workflow with Gerrit Code Review
Stable master workflow with Gerrit Code ReviewStable master workflow with Gerrit Code Review
Stable master workflow with Gerrit Code ReviewLuca Milanesio
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control SystemKMS Technology
 
Git Introduction
Git IntroductionGit Introduction
Git IntroductionGareth Hall
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubNick Quaranto
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentalsRajKharvar
 

Was ist angesagt? (20)

Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and Tags
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Git 101
Git 101Git 101
Git 101
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git github
Git githubGit github
Git github
 
Git-r-Done
Git-r-DoneGit-r-Done
Git-r-Done
 
Git
GitGit
Git
 
Stable master workflow with Gerrit Code Review
Stable master workflow with Gerrit Code ReviewStable master workflow with Gerrit Code Review
Stable master workflow with Gerrit Code Review
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
 
Git undo
Git undoGit undo
Git undo
 

Andere mochten auch

The Power of Gaming: A Brief Why, What, and How of Video Games in Libraries
The Power of Gaming: A Brief Why, What, and How of Video Games in LibrariesThe Power of Gaming: A Brief Why, What, and How of Video Games in Libraries
The Power of Gaming: A Brief Why, What, and How of Video Games in LibrariesMaggie Hommel Thomann
 
Business Leadership2
Business  Leadership2Business  Leadership2
Business Leadership2guest74023f
 
Experts On Credit Crisis
Experts On Credit CrisisExperts On Credit Crisis
Experts On Credit CrisisAvinash Singh
 
Measuring Your Nonprofit Marketing Success
Measuring Your Nonprofit Marketing SuccessMeasuring Your Nonprofit Marketing Success
Measuring Your Nonprofit Marketing SuccessKivi Leroux Miller
 
SNCR Award Winning Case Study on Reputation Management 2011
SNCR Award Winning Case Study on Reputation Management 2011SNCR Award Winning Case Study on Reputation Management 2011
SNCR Award Winning Case Study on Reputation Management 2011Shashi Bellamkonda
 
This is all such bullshit
This is all such bullshitThis is all such bullshit
This is all such bullshitJason Falls
 
Video Game Collection @ Your Library
Video Game Collection @ Your LibraryVideo Game Collection @ Your Library
Video Game Collection @ Your LibraryMaggie Hommel Thomann
 
eTwinning Communications
eTwinning CommunicationseTwinning Communications
eTwinning CommunicationsAlexa Joyce
 
6 Step Digression
6 Step Digression6 Step Digression
6 Step Digressionjzatko
 
Portfolio Feb08 r2
Portfolio Feb08 r2Portfolio Feb08 r2
Portfolio Feb08 r2guestf10f38
 
Toegankelijkheid
ToegankelijkheidToegankelijkheid
ToegankelijkheidAtticus
 
SYNOPSIS PELVIC PAIN RESEARCH
SYNOPSIS PELVIC PAIN RESEARCHSYNOPSIS PELVIC PAIN RESEARCH
SYNOPSIS PELVIC PAIN RESEARCHZia Khan
 
Innovation Equations
Innovation EquationsInnovation Equations
Innovation EquationsBen Ullman
 
Internet Marketing: Conversation marketing
Internet Marketing: Conversation marketingInternet Marketing: Conversation marketing
Internet Marketing: Conversation marketingIan Lurie
 

Andere mochten auch (20)

The Power of Gaming: A Brief Why, What, and How of Video Games in Libraries
The Power of Gaming: A Brief Why, What, and How of Video Games in LibrariesThe Power of Gaming: A Brief Why, What, and How of Video Games in Libraries
The Power of Gaming: A Brief Why, What, and How of Video Games in Libraries
 
Business Leadership2
Business  Leadership2Business  Leadership2
Business Leadership2
 
Experts On Credit Crisis
Experts On Credit CrisisExperts On Credit Crisis
Experts On Credit Crisis
 
Cicluri
CicluriCicluri
Cicluri
 
Measuring Your Nonprofit Marketing Success
Measuring Your Nonprofit Marketing SuccessMeasuring Your Nonprofit Marketing Success
Measuring Your Nonprofit Marketing Success
 
SNCR Award Winning Case Study on Reputation Management 2011
SNCR Award Winning Case Study on Reputation Management 2011SNCR Award Winning Case Study on Reputation Management 2011
SNCR Award Winning Case Study on Reputation Management 2011
 
This is all such bullshit
This is all such bullshitThis is all such bullshit
This is all such bullshit
 
Concierto
ConciertoConcierto
Concierto
 
Mikstreet Pr-2010
Mikstreet Pr-2010Mikstreet Pr-2010
Mikstreet Pr-2010
 
Video Game Collection @ Your Library
Video Game Collection @ Your LibraryVideo Game Collection @ Your Library
Video Game Collection @ Your Library
 
Present perfect
Present perfectPresent perfect
Present perfect
 
eTwinning Communications
eTwinning CommunicationseTwinning Communications
eTwinning Communications
 
6 Step Digression
6 Step Digression6 Step Digression
6 Step Digression
 
Portfolio Feb08 r2
Portfolio Feb08 r2Portfolio Feb08 r2
Portfolio Feb08 r2
 
TV lecture: Technology
TV lecture: TechnologyTV lecture: Technology
TV lecture: Technology
 
PeopleSoft
PeopleSoftPeopleSoft
PeopleSoft
 
Toegankelijkheid
ToegankelijkheidToegankelijkheid
Toegankelijkheid
 
SYNOPSIS PELVIC PAIN RESEARCH
SYNOPSIS PELVIC PAIN RESEARCHSYNOPSIS PELVIC PAIN RESEARCH
SYNOPSIS PELVIC PAIN RESEARCH
 
Innovation Equations
Innovation EquationsInnovation Equations
Innovation Equations
 
Internet Marketing: Conversation marketing
Internet Marketing: Conversation marketingInternet Marketing: Conversation marketing
Internet Marketing: Conversation marketing
 

Ähnlich wie Getting Started with Git

git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfmurad khan
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdfAliaaTarek5
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperJohn Stevenson
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with gitDídac Ríos
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheetsozone777
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
Git slides
Git slidesGit slides
Git slidesNanyak S
 
Git tutorial
Git tutorialGit tutorial
Git tutorialmobaires
 
Git for Beginners
Git for BeginnersGit for Beginners
Git for BeginnersRick Umali
 

Ähnlich wie Getting Started with Git (20)

git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheets
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Git slides
Git slidesGit slides
Git slides
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git for Beginners
Git for BeginnersGit for Beginners
Git for Beginners
 

Kürzlich hochgeladen

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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
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
 
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
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
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
 
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
 

Kürzlich hochgeladen (20)

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
 
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...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In 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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
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
 
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...
 
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...
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
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
 
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
 

Getting Started with Git

  • 1. Getting Started with Git 5/17/2012 This presentation is at: http://sn.im/startgit If you're on Google Docs, make sure to read the 'speaker notes' for this presentation. Rick Umali rickumali@gmail.com http://tech.rickumali.com/
  • 2. Questions I Plan to Answer What is source control? What is the big deal with Git? Can you show me a little Git? Commits. Branches. Merges. Remote repos.
  • 3. What is Source Control? A mechanism to track changes in source code. Used for version history, auditing, and recovery. Source code control is the most important practice a coding professional can do.
  • 5. Revision Control Example: Git This is what we'll be trying.
  • 6. Git Git is an open source, distributed version control system designed for speed and efficiency. ● Freedom ● No "server" required ● Unique architecture
  • 9. First Time Use: Set Up Tell Git who you are! % git config --global user.name "Rick Umali" % git config --global user.email "rickumali@gmail.com" Future 'commits' will show this information. % git config --list See "git config --help" for more configurations.
  • 10. Creating a "Repository" Let's pretend we're developing a Drupal module. % cd web/sites/all/modules % mkdir dumpstamp % cd dumpstamp % git init "git init" creates the entire Git repository. No server interaction required!
  • 11. Committing Your First File To 'commit' means 'to save the state' of your work. You must first 'add' this change to the 'staging area'. % vi README.txt % git add README.txt % git commit -m "First commit. README file." Use 'git help' to learn all the switches. -m stands for message.
  • 12. Looking at the Repository % git log Each 'commit' contains an ID, along with the author information from earlier, and a time stamp. % gitk GUI tools can help you visualize the 'repo.'
  • 13. Adding More Files % vi dumpstamp.info dumpstamp.module % git status % git add . % git commit This second commit saves the work of adding two files by using 'git add .'. The .module and .info files are the two required files for every Drupal module.
  • 14. Bonus: Creating a Module % drush pm-info dumpstamp % drush enable dumpstamp
  • 15. Examining Changes to Files % vi dumpstamp.module % git status % git diff % git add dumpstamp.module % git commit % git log The above is a typical 'workflow'. Git offers suggestions and hints as you use it.
  • 16. Doing More Changes % vi dumpstamp.module % git diff % git commit -a Or even: % git commit -a -m "Commit message." Another typical 'workflow'.
  • 17. Looking at the Log Again The history can be examined different ways. % git log % git log --format=short % git log --format=oneline % git log --oneline
  • 18. Revisiting History You can 'revisit' any point of your history. % git checkout SHAID Every commit is known by its SHA ID. This is the first step in making a branch! (Use git checkout master to revert.)
  • 19. Branching and Merging Next, But... What we have covered so far is probably 70- 80% of what you will do with git. Adding and committing files are the heart of git (and any version control system).
  • 20. Branching Git encourages experimentation, by making branching very easy.
  • 21. Branching: git checkout -b % git checkout -b BRANCH SHA1 Make some edits on a change below the master, then commit. git branch makes a branch from the branch you're on (default branch is 'master').
  • 22. Branching: Starting State NOTE: 'master' is a branch that's created 'by default'. master SHA 1A
  • 23. Branching: Make Some Changes git commit master SHA 2B SHA 1A
  • 24. Branching: Making a Branch git checkout -b branch1 SHA1 master SHA 2B SHA 1A branch1 NOTE: This command is a short cut for: git branch branch1 name_of_branch , then git checkout branch1 .
  • 25. Branching: Changes on the Branch (Make changes in branch1.) git commit master SHA 2B SHA 3C branch1 SHA 1A
  • 27. Merging Bringing two branches together. Git calculates the correct 'merge base'. First 'checkout' the branch you want to merge into (typically master), then 'merge' the branch. % git checkout master % git merge BRANCH
  • 28. Merging: Starting State git branch master SHA 2B SHA 3C branch1 SHA 1A
  • 29. Merging: Two Steps git checkout master git merge branch1 master SHA 4D SHA 2B SHA 3C branch1 SHA 1A
  • 30. Merging: The Hard Part Manual 'merging' may be required.
  • 32. Whew!
  • 33. Remote Branches You can 'browse' public Git repositories for code that you want to examine or use. You can upload a local Git repository to a public Git repository.
  • 34. Common Public Git Repositories
  • 35. Browsing and Grabbing Code git clone git@github.com:rickumali/RickUmaliVanityWebsite. git
  • 36. Uploading Code (to Github) Create a key pair on your machine. Create a repository (on Github). Add a 'remote' (via git remote add). Upload your code (via git push).
  • 39. Adding a Remote, then Upload
  • 40. After An Upload (to Github) git clone git@github.com:rickumali/DumpStamp.git
  • 41. Next Steps Install Git. Commit your code changes frequently. Log verbosely (in commit messages). Experiment (branch) often.
  • 42. Resources http://git-scm.org/ Both "Pro Git" book, and Git reference http://gitref.org/ A "quicker" Git reference http://www-cs-students.stanford.edu/~blynn/gitmagic/ "Friendlier" Git walk-through (git magic). http://drupal.org/node/803746 A workflow for using Git with Drupal. http://www.mail-archive.com/dri-devel@lists.sourceforge. net/msg39091.html Linus on "clean history."
  • 43. Resources http://www.youtube.com/watch?v=4XpnKHJAok8 Linus Torvalds (Git creator) (May '07) http://www.youtube.com/watch?v=8dhZ9BXQgc4 Randal Schwartz (Perl expert and Git old-timer) (Oct '07) http://www.youtube.com/watch?v=ZDR433b0HJY Scott Chacon (Pro Git author) (July '11)
  • 44. Getting Started with Git Thank you! Rick Umali rickumali@gmail.com http://tech.rickumali.com/