SlideShare a Scribd company logo
Git Introduction
Fast Version Control
Who am I
• Gareth Hall
• Lead Developer and Hyundai New Zealand
• Director at Communica
(http://communica.co.nz)
What is git?
• Git is a distribute version control system
developed by Junio Hamano & Linus
Torvalds.
• Git does not use a centralised server.
• Git runs on major operating system like OS
X, Windows, Unix & Linux
Why it’s named git?
• Quoting Linus: “I’m egotistical, and I name
all my projects after myself. First Linux, now
git”
• Def: git - British slang for “pig headed, they
are always correct , argumentative”
What does git do?
• Git tracks changes to content.
Advantages of git
• Everything is local (almost)
• Fast
• Every clone / branch is a backup
• Work offline
• No single point of failure
• Lightweight
• Branching is cheap and merging is easy
• Many different workflows possible
• Distributed
• Every file and commit is checksummed
• Staging area
• Free and open source
Three States
Individual Workflow
Collaborative Workflow
Gitflow 1
Gitflow II
Basic Commands
Syntax: git <subcmd>
git init
•Create an empty git repository or reinitialize
an existing one
#:>git init
Initialized empty Git repository in
/Users/garethhall/Sites/git_intro/.git/
git status
• Show the working tree status
#:>git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# includes/
# index.php
nothing added to commit but untracked files present (use "git add" to track)
git add
• Add file contents to the index
• git add .
• git add <filename> <filenname>
git status
#:>git add .
#:>git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: includes/helpers.php
# new file: index.php
#
git commit
•Record changes to the repository
#:>git commit -m "first commit"
[master (root-commit) 5f8a8d4] first commit
2 files changed, 48 insertions(+)
create mode 100644 includes/helpers.php
create mode 100644 index.php
git log
•Show commit logs
#:>git log
commit 5f8a8d486ae1656b51194186c0dfb97ae1ec9835
Author: Gareth Hall <gareth@communica.co.nz>
Date: Sat Feb 16 14:43:40 2013 +1300
first commit
Edit files
#:>git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: includes/helpers.php
# modified: index.php
#
no changes added to commit (use "git add" and/or "git commit -a")
#:>git add index.php
#:>git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: index.php
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: includes/helpers.php
#
• #:>git commit -m "Changed output to table"
[master fffacb4] Changed output to table
1 file changed, 10 insertions(+), 2 deletions(-)
#:>git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: includes/helpers.php
#
no changes added to commit (use "git add" and/or "git commit -a")
#:>git log
commit fffacb43627c5a44850b4b1543dc359f5d95edd6
Author: Gareth Hall <gareth@communica.co.nz>
Date: Sat Feb 16 16:10:45 2013 +1300
Changed output to table
commit 5f8a8d486ae1656b51194186c0dfb97ae1ec9835
Author: Gareth Hall <gareth@communica.co.nz>
Date: Sat Feb 16 14:43:40 2013 +1300
first commit
#:>git diff includes/helpers.php
diff --git a/includes/helpers.php b/includes/helpers.php
index 5c9a1fe..002256c 100644
--- a/includes/helpers.php
+++ b/includes/helpers.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Pretty Print Helper
*
@@ -28,6 +27,12 @@ function dd($data, $die = false)
{
echo '<pre>';
var_dump($data);
- echo '</pre>';
- $die ? die() : null;
-}
 No newline at end of file
+ echo '</pre>';
+ $die ? die() : null;
+}
+
+function logger($user_id, $message)
+{
+ $log_entry = $user_id . ',' . $message;
+ return file_put_contents('log.log', $log_entry) ? true : false;
+}
git diff
#:>git add .
#:>git commit -m "Added logger"
[master 817dee6] Added logger
1 file changed, 9 insertions(+), 4 deletions(-)
#:>git log --oneline --decorate
817dee6 (HEAD, master) Added logger
fffacb4 Changed output to table
5f8a8d4 first commit
git show• Show various types of objects
#:>git show fffacb4
commit fffacb43627c5a44850b4b1543dc359f5d95edd6
Author: Gareth Hall <gareth@communica.co.nz>
Date: Sat Feb 16 16:10:45 2013 +1300
Changed output to table
diff --git a/index.php b/index.php
index f1f4a05..df11b0b 100644
--- a/index.php
+++ b/index.php
@@ -10,6 +10,14 @@ if (($xml = @simplexml_load_file('https://www.bnz.co.nz/XMLFeed/portal/fcs/xml')
}
}
-pp($bnz_rates, true);
-
+print '<table border="1">';
+ print '<tr>';
+ print '<th>Code</th><th>Rate</th>';
+ print '</tr>';
+ foreach ($bnz_rates as $code => $rate){
+ print '<tr>';
+ print '<th>' . $code . '</th><th>' . $rate . '</th>';
+ print '</tr>';
+ }
+print '</table>';
git branch
•List, create, or delete branches
#:>git branch outputHelper
#:>git branch
* master
outputHelper
git checkout
•Checkout a branch or paths to the working tree
#:>git checkout outputHelper
Switched to branch 'outputHelper'
#:>git branch
master
* outputHelper
Develop new Feature
#:>git status
# On branch outputHelper
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: includes/helpers.php
# modified: index.php
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# includes/.DS_Store
# includes/output_helper.php
no changes added to commit (use "git add" and/or "git commit -a")
#:>git add includes/helpers.php
#:>git commit -m 'Added doc block to logger function'
[outputHelper df78fc4] Added doc block to logger function
1 file changed, 8 insertions(+)
#:>git commit -a -m 'Refactored with new table output helper'
[outputHelper 51da4b7] Refactored with new table output helper
3 files changed, 38 insertions(+), 11 deletions(-)
create mode 100644 includes/.DS_Store
create mode 100644 includes/output_helper.php
#:>git log --oneline --decorate --graph
* 51da4b7 (HEAD, outputHelper) Refactored with new table output helper
* df78fc4 Added doc block to logger function
* 817dee6 (master) Added logger
* fffacb4 Changed output to table
* 5f8a8d4 first commit
#:>git checkout master
Switched to branch 'master'
#:>git log --oneline --decorate --graph
* 817dee6 (HEAD, master) Added logger
* fffacb4 Changed output to table
* 5f8a8d4 first commit
git merge
• Join two or more development histories together
#:>git merge outputHelper
Updating 817dee6..51da4b7
Fast-forward
includes/.DS_Store | Bin 0 -> 6148 bytes
includes/helpers.php | 8 ++++++++
includes/output_helper.php | 36 ++++++++++++++++++++++++++++++++++++
index.php | 13 ++-----------
4 files changed, 46 insertions(+), 11 deletions(-)
create mode 100644 includes/.DS_Store
create mode 100644 includes/output_helper.php
#:>git log --oneline --decorate --graph
* 51da4b7 (HEAD, outputHelper, master) Refactored with new
table output helper
* df78fc4 Added doc block to logger function
* 817dee6 Added logger
* fffacb4 Changed output to table
* 5f8a8d4 first commit
git reset
• Reset current HEAD to the specified state
git push
• Update remote refs along with associated
objects
git fetch
• Download objects and refs from another
repository
git merge
• Join two or more development histories
together
git pull
• Fetch from and merge with another
repository or a local branch
• fetch + merge
How in Drupal?
• Add all of Drupal to git
• Use the Features module to move
configuration
• UUID Features to move content (alpha!)
Git Hosting Service
• Bitbucket (htt://bitbucket.org)
• Github (http://github.com)
• Run your own
• Gitosis
• Gitolite
Deployment
• Shell Access
• Continous Integration
• I don’t have shell access
• Setup your server as a remote
Deployment with shell
Continous Intergration
• Heroku (http://heroku.com)
• Pagoda (http://pagodabox.com)
• Bamboo
(http://atlassian.com/software/bamboo)
I don’t have shell
• Deploy (http://www.deployhq.com)
Server as Remote
• Will need to use git hooks
Git Hooks
Git Hooks
• #>vim post-receive
• #!/bin/sh
• cd ..
• GIT_DIR='.git'
• umask 002 && git reset --hard
Git GUI’s
Resources
• Git (http://git-scm.com)
• Wiki
(http://en.wikipedia.org/wiki/Git_(software)
)
• Git Essentials
(https://tutsplus.com/course/git-essentials/)
• Change Management andVersion Control
(http://buildamodule.com)
Visual Version Control
Gource (http://code.google.com/p/gource/)
Questions

More Related Content

What's hot

Learning git
Learning gitLearning git
Learning git
Sid Anand
 
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
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
Krunal Doshi
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
Md. Ahsan Habib Nayan
 
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
Geoff Hoffman
 
Introduction to Gitlab
Introduction to GitlabIntroduction to Gitlab
Introduction to Gitlab
Julien Pivotto
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
Kumar Shìvam
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
Fran García
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
Anwarul Islam
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
Dilum Navanjana
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Roland Emmanuel Salunga
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub

What's hot (20)

Learning git
Learning gitLearning git
Learning git
 
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
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
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
 
Introduction to Gitlab
Introduction to GitlabIntroduction to Gitlab
Introduction to Gitlab
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 

Viewers also liked

Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Nazarovo_administration
 
Афиша культурных мероприятий на сентябрь 2013
Афиша культурных мероприятий на сентябрь 2013Афиша культурных мероприятий на сентябрь 2013
Афиша культурных мероприятий на сентябрь 2013Nazarovo_administration
 
SACH MY THUAT
SACH MY THUATSACH MY THUAT
SACH MY THUAT
archshop vn
 
Field trips project
Field trips projectField trips project
Field trips project
jaimefoster3
 
ส งคม
ส งคมส งคม
ส งคม280125399
 
Poder para salvar
Poder para salvarPoder para salvar
Poder para salvar
joaovitormreis
 
Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.Nazarovo_administration
 
Афиша культурных событий март 2014
Афиша культурных событий март 2014Афиша культурных событий март 2014
Афиша культурных событий март 2014Nazarovo_administration
 
Разъяснения минпромторга рф
Разъяснения минпромторга рфРазъяснения минпромторга рф
Разъяснения минпромторга рф
Nazarovo_administration
 
Мероприятия, посвященные Международному дню инвалидов
Мероприятия, посвященные Международному дню инвалидовМероприятия, посвященные Международному дню инвалидов
Мероприятия, посвященные Международному дню инвалидовNazarovo_administration
 
Афиша культурных мероприятий на декабрь
Афиша культурных мероприятий на декабрьАфиша культурных мероприятий на декабрь
Афиша культурных мероприятий на декабрьNazarovo_administration
 
Yet Another Hack
Yet Another HackYet Another Hack
Yet Another Hack
Mikhail Klyuev
 
Blunt Umbrellas Website Showcase
Blunt Umbrellas Website ShowcaseBlunt Umbrellas Website Showcase
Blunt Umbrellas Website Showcase
Gareth Hall
 
Реестр муниципальных услуг
Реестр муниципальных услугРеестр муниципальных услуг
Реестр муниципальных услугNazarovo_administration
 
Praktikum Pengenalan Dasar Database
Praktikum Pengenalan Dasar DatabasePraktikum Pengenalan Dasar Database
Praktikum Pengenalan Dasar Database
Riz Al-Atsary (Abu Uwais)
 
Langkah mudah memahami pembuatan dns server ubuntu 12.04
Langkah mudah memahami pembuatan dns server ubuntu 12.04Langkah mudah memahami pembuatan dns server ubuntu 12.04
Langkah mudah memahami pembuatan dns server ubuntu 12.04
Riz Al-Atsary (Abu Uwais)
 
Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Nazarovo_administration
 

Viewers also liked (20)

Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"
 
Афиша культурных мероприятий на сентябрь 2013
Афиша культурных мероприятий на сентябрь 2013Афиша культурных мероприятий на сентябрь 2013
Афиша культурных мероприятий на сентябрь 2013
 
SACH MY THUAT
SACH MY THUATSACH MY THUAT
SACH MY THUAT
 
Field trips project
Field trips projectField trips project
Field trips project
 
ส งคม
ส งคมส งคม
ส งคม
 
Poder para salvar
Poder para salvarPoder para salvar
Poder para salvar
 
Shekinah
ShekinahShekinah
Shekinah
 
Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.
 
Афиша культурных событий март 2014
Афиша культурных событий март 2014Афиша культурных событий март 2014
Афиша культурных событий март 2014
 
3 квартал рейтинг
3 квартал рейтинг 3 квартал рейтинг
3 квартал рейтинг
 
Разъяснения минпромторга рф
Разъяснения минпромторга рфРазъяснения минпромторга рф
Разъяснения минпромторга рф
 
Мероприятия, посвященные Международному дню инвалидов
Мероприятия, посвященные Международному дню инвалидовМероприятия, посвященные Международному дню инвалидов
Мероприятия, посвященные Международному дню инвалидов
 
Афиша культурных мероприятий на декабрь
Афиша культурных мероприятий на декабрьАфиша культурных мероприятий на декабрь
Афиша культурных мероприятий на декабрь
 
Yet Another Hack
Yet Another HackYet Another Hack
Yet Another Hack
 
Blunt Umbrellas Website Showcase
Blunt Umbrellas Website ShowcaseBlunt Umbrellas Website Showcase
Blunt Umbrellas Website Showcase
 
Реестр муниципальных услуг
Реестр муниципальных услугРеестр муниципальных услуг
Реестр муниципальных услуг
 
Капитальный ремонт
Капитальный ремонтКапитальный ремонт
Капитальный ремонт
 
Praktikum Pengenalan Dasar Database
Praktikum Pengenalan Dasar DatabasePraktikum Pengenalan Dasar Database
Praktikum Pengenalan Dasar Database
 
Langkah mudah memahami pembuatan dns server ubuntu 12.04
Langkah mudah memahami pembuatan dns server ubuntu 12.04Langkah mudah memahami pembuatan dns server ubuntu 12.04
Langkah mudah memahami pembuatan dns server ubuntu 12.04
 
Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"
 

Similar to Git Introduction

Git Acquainted
Git AcquaintedGit Acquainted
Git Acquainted
tylerhunt
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
Yoram Michaeli
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
Advanted git
Advanted git Advanted git
Advanted git
Sahil Gupta
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
Things Lab
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Piotr Benetkiewicz
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Git_real_slides
Git_real_slidesGit_real_slides
Git_real_slides
Khanh NL-bantoilatoi
 
Git
Git Git
Gittalk
GittalkGittalk
Gittalk
prtinsley
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
Raja Soundaramourty
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
srinathcox
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
E Carter
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Andrej Koelewijn
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 

Similar to Git Introduction (20)

Git Acquainted
Git AcquaintedGit Acquainted
Git Acquainted
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Advanted git
Advanted git Advanted git
Advanted git
 
Git github
Git githubGit github
Git github
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git_real_slides
Git_real_slidesGit_real_slides
Git_real_slides
 
Git
Git Git
Git
 
Gittalk
GittalkGittalk
Gittalk
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Git introduction
Git introductionGit introduction
Git introduction
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 

Recently uploaded

一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Luigi Fugaro
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Optimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptxOptimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptx
WebConnect Pvt Ltd
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 

Recently uploaded (20)

一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Optimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptxOptimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptx
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 

Git Introduction

  • 2. Who am I • Gareth Hall • Lead Developer and Hyundai New Zealand • Director at Communica (http://communica.co.nz)
  • 3. What is git? • Git is a distribute version control system developed by Junio Hamano & Linus Torvalds. • Git does not use a centralised server. • Git runs on major operating system like OS X, Windows, Unix & Linux
  • 4. Why it’s named git? • Quoting Linus: “I’m egotistical, and I name all my projects after myself. First Linux, now git” • Def: git - British slang for “pig headed, they are always correct , argumentative”
  • 5. What does git do? • Git tracks changes to content.
  • 6. Advantages of git • Everything is local (almost) • Fast • Every clone / branch is a backup • Work offline • No single point of failure • Lightweight • Branching is cheap and merging is easy • Many different workflows possible • Distributed • Every file and commit is checksummed • Staging area • Free and open source
  • 13. git init •Create an empty git repository or reinitialize an existing one #:>git init Initialized empty Git repository in /Users/garethhall/Sites/git_intro/.git/
  • 14. git status • Show the working tree status #:>git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # includes/ # index.php nothing added to commit but untracked files present (use "git add" to track)
  • 15. git add • Add file contents to the index • git add . • git add <filename> <filenname>
  • 16. git status #:>git add . #:>git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: includes/helpers.php # new file: index.php #
  • 17. git commit •Record changes to the repository #:>git commit -m "first commit" [master (root-commit) 5f8a8d4] first commit 2 files changed, 48 insertions(+) create mode 100644 includes/helpers.php create mode 100644 index.php
  • 18. git log •Show commit logs #:>git log commit 5f8a8d486ae1656b51194186c0dfb97ae1ec9835 Author: Gareth Hall <gareth@communica.co.nz> Date: Sat Feb 16 14:43:40 2013 +1300 first commit
  • 20. #:>git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: includes/helpers.php # modified: index.php # no changes added to commit (use "git add" and/or "git commit -a")
  • 21. #:>git add index.php #:>git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: index.php # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: includes/helpers.php #
  • 22. • #:>git commit -m "Changed output to table" [master fffacb4] Changed output to table 1 file changed, 10 insertions(+), 2 deletions(-) #:>git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: includes/helpers.php # no changes added to commit (use "git add" and/or "git commit -a")
  • 23. #:>git log commit fffacb43627c5a44850b4b1543dc359f5d95edd6 Author: Gareth Hall <gareth@communica.co.nz> Date: Sat Feb 16 16:10:45 2013 +1300 Changed output to table commit 5f8a8d486ae1656b51194186c0dfb97ae1ec9835 Author: Gareth Hall <gareth@communica.co.nz> Date: Sat Feb 16 14:43:40 2013 +1300 first commit
  • 24. #:>git diff includes/helpers.php diff --git a/includes/helpers.php b/includes/helpers.php index 5c9a1fe..002256c 100644 --- a/includes/helpers.php +++ b/includes/helpers.php @@ -1,5 +1,4 @@ <?php - /** * Pretty Print Helper * @@ -28,6 +27,12 @@ function dd($data, $die = false) { echo '<pre>'; var_dump($data); - echo '</pre>'; - $die ? die() : null; -} No newline at end of file + echo '</pre>'; + $die ? die() : null; +} + +function logger($user_id, $message) +{ + $log_entry = $user_id . ',' . $message; + return file_put_contents('log.log', $log_entry) ? true : false; +} git diff
  • 25. #:>git add . #:>git commit -m "Added logger" [master 817dee6] Added logger 1 file changed, 9 insertions(+), 4 deletions(-) #:>git log --oneline --decorate 817dee6 (HEAD, master) Added logger fffacb4 Changed output to table 5f8a8d4 first commit
  • 26. git show• Show various types of objects #:>git show fffacb4 commit fffacb43627c5a44850b4b1543dc359f5d95edd6 Author: Gareth Hall <gareth@communica.co.nz> Date: Sat Feb 16 16:10:45 2013 +1300 Changed output to table diff --git a/index.php b/index.php index f1f4a05..df11b0b 100644 --- a/index.php +++ b/index.php @@ -10,6 +10,14 @@ if (($xml = @simplexml_load_file('https://www.bnz.co.nz/XMLFeed/portal/fcs/xml') } } -pp($bnz_rates, true); - +print '<table border="1">'; + print '<tr>'; + print '<th>Code</th><th>Rate</th>'; + print '</tr>'; + foreach ($bnz_rates as $code => $rate){ + print '<tr>'; + print '<th>' . $code . '</th><th>' . $rate . '</th>'; + print '</tr>'; + } +print '</table>';
  • 27. git branch •List, create, or delete branches #:>git branch outputHelper #:>git branch * master outputHelper
  • 28. git checkout •Checkout a branch or paths to the working tree #:>git checkout outputHelper Switched to branch 'outputHelper' #:>git branch master * outputHelper
  • 30. #:>git status # On branch outputHelper # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: includes/helpers.php # modified: index.php # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # includes/.DS_Store # includes/output_helper.php no changes added to commit (use "git add" and/or "git commit -a")
  • 31. #:>git add includes/helpers.php #:>git commit -m 'Added doc block to logger function' [outputHelper df78fc4] Added doc block to logger function 1 file changed, 8 insertions(+) #:>git commit -a -m 'Refactored with new table output helper' [outputHelper 51da4b7] Refactored with new table output helper 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 includes/.DS_Store create mode 100644 includes/output_helper.php
  • 32. #:>git log --oneline --decorate --graph * 51da4b7 (HEAD, outputHelper) Refactored with new table output helper * df78fc4 Added doc block to logger function * 817dee6 (master) Added logger * fffacb4 Changed output to table * 5f8a8d4 first commit #:>git checkout master Switched to branch 'master' #:>git log --oneline --decorate --graph * 817dee6 (HEAD, master) Added logger * fffacb4 Changed output to table * 5f8a8d4 first commit
  • 33. git merge • Join two or more development histories together #:>git merge outputHelper Updating 817dee6..51da4b7 Fast-forward includes/.DS_Store | Bin 0 -> 6148 bytes includes/helpers.php | 8 ++++++++ includes/output_helper.php | 36 ++++++++++++++++++++++++++++++++++++ index.php | 13 ++----------- 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 includes/.DS_Store create mode 100644 includes/output_helper.php
  • 34. #:>git log --oneline --decorate --graph * 51da4b7 (HEAD, outputHelper, master) Refactored with new table output helper * df78fc4 Added doc block to logger function * 817dee6 Added logger * fffacb4 Changed output to table * 5f8a8d4 first commit
  • 35. git reset • Reset current HEAD to the specified state
  • 36. git push • Update remote refs along with associated objects
  • 37. git fetch • Download objects and refs from another repository
  • 38. git merge • Join two or more development histories together
  • 39. git pull • Fetch from and merge with another repository or a local branch • fetch + merge
  • 40. How in Drupal? • Add all of Drupal to git • Use the Features module to move configuration • UUID Features to move content (alpha!)
  • 41. Git Hosting Service • Bitbucket (htt://bitbucket.org) • Github (http://github.com) • Run your own • Gitosis • Gitolite
  • 42. Deployment • Shell Access • Continous Integration • I don’t have shell access • Setup your server as a remote
  • 44. Continous Intergration • Heroku (http://heroku.com) • Pagoda (http://pagodabox.com) • Bamboo (http://atlassian.com/software/bamboo)
  • 45. I don’t have shell • Deploy (http://www.deployhq.com)
  • 46. Server as Remote • Will need to use git hooks
  • 48. Git Hooks • #>vim post-receive • #!/bin/sh • cd .. • GIT_DIR='.git' • umask 002 && git reset --hard
  • 50. Resources • Git (http://git-scm.com) • Wiki (http://en.wikipedia.org/wiki/Git_(software) ) • Git Essentials (https://tutsplus.com/course/git-essentials/) • Change Management andVersion Control (http://buildamodule.com)
  • 51. Visual Version Control Gource (http://code.google.com/p/gource/)