SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
habeeb rahman | hrahman@apigee.com | pk.habi@gmail.com
Get on with Git
topics
git way
basic commands
git way
direct acyclic graph
sha-1 hash
git objects: blob tree commit tag
sha-1 & blob
(master) $ echo -e 'blob 140Hello, World!' | shasum
8ab686eafeb1f44702738c8b0f24f2567c36da6d
(master) $ echo 'Hello, World!' | git hash-object -w --stdin
8ab686eafeb1f44702738c8b0f24f2567c36da6d
(master) $ ls .git/objects/8a
b686eafeb1f44702738c8b0f24f2567c36da6d
(master) $ git show 8ab686eafeb1f44702738c8b0f24f2567c36da6d
Hello, World!
sha-1 & blob
(master)$ git cat-file -p 8ab686eafeb1f44702738c8b0f24f2567c36da6d
Hello, World!
(master)$ git cat-file -t 8ab686eafeb1f44702738c8b0f24f2567c36da6d
blob
sha-1 and tree
git cat-file -p master^{tree}
sha-1 and commit
(master)$ git show
commit 0184521b4bc88bbb67891ed740140147c9ce61cd
Author: Habeeb Rahman <hrahman@apigee.com>
Date:......
(master)$ git cat-file -t 0184521b4bc88bbb67891ed740140147c9ce61cd
commit
behind the scene
working directory
working
directory git add
committed
snapshotgit commit
index
(stage)
Basic commands
first things first
let git know your name and email:
git config --global user.name "Your Name"
git config --global user.email "your_email@whatever.com"
git init
Create an empty git repository or reinitialize an existing one
$ mkdir getonwithgit
$ cd getonwithgit/
$ git init
Initialized empty Git repository in /Users/hrahman/test/getonwithgit/.git/
git add
(master)$ echo "Hello World" > hello.txt
(master)$ git status
# On branch master
# Initial commit
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# hello.txt
nothing added to commit but untracked files present (use "git add" to track)
(master)$ git add hello.txt
(master)$ git status
# On branch master
# Initial commit
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
# new file: hello.txt
git commit
(master)$ git commit -m "first commit"
[master (root-commit) 05e96c3] first commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 hello.txt
(master)$ git show
commit 05e96c39452126e9310e84203af72f141c37a493
Author: Habeeb Rahman <hrahman@apigee.com>
Date: Tue Jun 18 13:46:35 2013 +0530
first commit
diff --git a/hello.txt b/hello.txt
new file mode 100644
index 0000000..557db03
--- /dev/null
+++ b/hello.txt
@@ -0,0 +1 @@
+Hello World
git diff
git diff: Show differences between your working directory and the
index.
git diff –cached: Show differences between the index and the
most recent commit.
git diff HEAD: Show the differences between your working
directory and the most recent commit.
git commit --amend
you commit and then realize you forgot to stage the changes in a file
you wanted to add to this commit:
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
branch
create a new branch:
(master)$ git checkout -b dev_feature
Switched to a new branch 'dev_feature'
switch to an existing branch:
(dev_feature)$ git checkout master
Switched to branch 'master'
(dev_feature)$ echo "new feature" > feature.txt
(dev_feature)$ git add feature.txt
(dev_feature)$ git commit -m "feature"
branch
delete a branch
$git branch -d dev_new_branch
show all local branches:
$git branch
show all local and remote branches:
$git branch -a
branch & merge
merge
merge 'dev_feature' branch into 'master':
(dev_feature)$ git checkout master
Switched to branch 'master'
find out what's going to be merged:
(master)$ git diff master...dev_feature
diff --git a/feature.txt b/feature.txt
new file mode 100644
index 0000000..2c61ec4
--- /dev/null
+++ b/feature.txt
@@ -0,0 +1 @@
+new feature added
(master)$ git merge dev_feature
Updating 05e96c3..70c1e30
Fast-forward
feature.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 feature.txt
git blame
(master)$ git blame feature.txt
70c1e306 (Habeeb Rahman 2013-06-18 15:50:47 +0530 1) new
feature added
git log
(master)$ git log
commit 70c1e3069a68877fca9680b045185288c5201a46
Author: Habeeb Rahman <hrahman@apigee.com>
Date: Tue Jun 18 15:50:47 2013 +0530
feature
commit 05e96c39452126e9310e84203af72f141c37a493
Author: Habeeb Rahman <hrahman@apigee.com>
Date: Tue Jun 18 13:46:35 2013 +0530
first commit
(master)$ git log --oneline
70c1e30 feature
05e96c3 first commit
git grep
(master)$ git grep hello
hello.txt:hello world
new.txt:hello everyone
git clone
Local:
git clone /path/to/repository
Remote:
git clone git://github.com/sample/test.git
git help
display help information about git
$ git help help
$ git help grep
$ git help reset
further reading
http://git-scm.com/book
http://think-like-a-git.net/
http://ftp.newartisans.com/pub/git.from.bottom.up.pdf

Más contenido relacionado

La actualidad más candente

名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、GaelykでハンズオンTsuyoshi Yamamoto
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~Tsuyoshi Yamamoto
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! GrailsプラグインTsuyoshi Yamamoto
 
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」Tsuyoshi Yamamoto
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetAbdul Basit
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
The Django Book CH13 Generating Non-HTML Content
The Django Book CH13 Generating Non-HTML ContentThe Django Book CH13 Generating Non-HTML Content
The Django Book CH13 Generating Non-HTML ContentJohnny Wang
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer CheatsheetAbdul Basit
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Tsuyoshi Yamamoto
 
Introduction to cron queue
Introduction to cron queueIntroduction to cron queue
Introduction to cron queueADCI Solutions
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetBruce McPherson
 

La actualidad más candente (20)

G* on GAE/J 挑戦編
G* on GAE/J 挑戦編G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
 
Gaelyk
GaelykGaelyk
Gaelyk
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
 
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
 
Virthualenvwrapper
VirthualenvwrapperVirthualenvwrapper
Virthualenvwrapper
 
17.my sql triggers in laravel
17.my sql triggers in laravel17.my sql triggers in laravel
17.my sql triggers in laravel
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Cakephpstudy5 hacks
Cakephpstudy5 hacksCakephpstudy5 hacks
Cakephpstudy5 hacks
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Ohh shit git
Ohh shit gitOhh shit git
Ohh shit git
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Git
GitGit
Git
 
The Django Book CH13 Generating Non-HTML Content
The Django Book CH13 Generating Non-HTML ContentThe Django Book CH13 Generating Non-HTML Content
The Django Book CH13 Generating Non-HTML Content
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
 
Introduction to cron queue
Introduction to cron queueIntroduction to cron queue
Introduction to cron queue
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
 

Destacado

Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureHabeeb Rahman
 
Accept paradigm shifts to Accelerate devops
Accept paradigm shifts to Accelerate devopsAccept paradigm shifts to Accelerate devops
Accept paradigm shifts to Accelerate devopsHabeeb Rahman
 
Witness statement
Witness statementWitness statement
Witness statementLola Heavey
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppetHabeeb Rahman
 

Destacado (6)

Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
 
Accept paradigm shifts to Accelerate devops
Accept paradigm shifts to Accelerate devopsAccept paradigm shifts to Accelerate devops
Accept paradigm shifts to Accelerate devops
 
DNS in the Cloud
DNS in the CloudDNS in the Cloud
DNS in the Cloud
 
Witness statement
Witness statementWitness statement
Witness statement
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppet
 
JSON-LD Update
JSON-LD UpdateJSON-LD Update
JSON-LD Update
 

Similar a Get on with git

Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHubLucas Videla
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji3camp
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Codemotion
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With GitHoffman Lab
 
slides.pdf
slides.pdfslides.pdf
slides.pdfvidsvagi
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)bryanbibat
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemTommaso Visconti
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginnersbryanbibat
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
もっとgit
もっとgitもっとgit
もっとgitJoe_noh
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugSébastien Deleuze
 

Similar a Get on with git (20)

git internals
git internalsgit internals
git internals
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Git internals
Git internalsGit internals
Git internals
 
Git
GitGit
Git
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
slides.pdf
slides.pdfslides.pdf
slides.pdf
 
slides.pdf
slides.pdfslides.pdf
slides.pdf
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
Git Basic
Git BasicGit Basic
Git Basic
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
 
git command
git commandgit command
git command
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
もっとgit
もっとgitもっとgit
もっとgit
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJug
 

Último

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
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
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
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
 

Get on with git

  • 1. habeeb rahman | hrahman@apigee.com | pk.habi@gmail.com Get on with Git
  • 3. git way direct acyclic graph sha-1 hash git objects: blob tree commit tag
  • 4. sha-1 & blob (master) $ echo -e 'blob 140Hello, World!' | shasum 8ab686eafeb1f44702738c8b0f24f2567c36da6d (master) $ echo 'Hello, World!' | git hash-object -w --stdin 8ab686eafeb1f44702738c8b0f24f2567c36da6d (master) $ ls .git/objects/8a b686eafeb1f44702738c8b0f24f2567c36da6d (master) $ git show 8ab686eafeb1f44702738c8b0f24f2567c36da6d Hello, World!
  • 5. sha-1 & blob (master)$ git cat-file -p 8ab686eafeb1f44702738c8b0f24f2567c36da6d Hello, World! (master)$ git cat-file -t 8ab686eafeb1f44702738c8b0f24f2567c36da6d blob
  • 6. sha-1 and tree git cat-file -p master^{tree}
  • 7. sha-1 and commit (master)$ git show commit 0184521b4bc88bbb67891ed740140147c9ce61cd Author: Habeeb Rahman <hrahman@apigee.com> Date:...... (master)$ git cat-file -t 0184521b4bc88bbb67891ed740140147c9ce61cd commit
  • 8. behind the scene working directory working directory git add committed snapshotgit commit index (stage)
  • 10. first things first let git know your name and email: git config --global user.name "Your Name" git config --global user.email "your_email@whatever.com"
  • 11. git init Create an empty git repository or reinitialize an existing one $ mkdir getonwithgit $ cd getonwithgit/ $ git init Initialized empty Git repository in /Users/hrahman/test/getonwithgit/.git/
  • 12. git add (master)$ echo "Hello World" > hello.txt (master)$ git status # On branch master # Initial commit # Untracked files: # (use "git add <file>..." to include in what will be committed) # hello.txt nothing added to commit but untracked files present (use "git add" to track) (master)$ git add hello.txt (master)$ git status # On branch master # Initial commit # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # new file: hello.txt
  • 13. git commit (master)$ git commit -m "first commit" [master (root-commit) 05e96c3] first commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 hello.txt (master)$ git show commit 05e96c39452126e9310e84203af72f141c37a493 Author: Habeeb Rahman <hrahman@apigee.com> Date: Tue Jun 18 13:46:35 2013 +0530 first commit diff --git a/hello.txt b/hello.txt new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/hello.txt @@ -0,0 +1 @@ +Hello World
  • 14. git diff git diff: Show differences between your working directory and the index. git diff –cached: Show differences between the index and the most recent commit. git diff HEAD: Show the differences between your working directory and the most recent commit.
  • 15. git commit --amend you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit: $ git commit -m 'initial commit' $ git add forgotten_file $ git commit --amend
  • 16. branch create a new branch: (master)$ git checkout -b dev_feature Switched to a new branch 'dev_feature' switch to an existing branch: (dev_feature)$ git checkout master Switched to branch 'master' (dev_feature)$ echo "new feature" > feature.txt (dev_feature)$ git add feature.txt (dev_feature)$ git commit -m "feature"
  • 17. branch delete a branch $git branch -d dev_new_branch show all local branches: $git branch show all local and remote branches: $git branch -a
  • 19. merge merge 'dev_feature' branch into 'master': (dev_feature)$ git checkout master Switched to branch 'master' find out what's going to be merged: (master)$ git diff master...dev_feature diff --git a/feature.txt b/feature.txt new file mode 100644 index 0000000..2c61ec4 --- /dev/null +++ b/feature.txt @@ -0,0 +1 @@ +new feature added (master)$ git merge dev_feature Updating 05e96c3..70c1e30 Fast-forward feature.txt | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 feature.txt
  • 20. git blame (master)$ git blame feature.txt 70c1e306 (Habeeb Rahman 2013-06-18 15:50:47 +0530 1) new feature added
  • 21. git log (master)$ git log commit 70c1e3069a68877fca9680b045185288c5201a46 Author: Habeeb Rahman <hrahman@apigee.com> Date: Tue Jun 18 15:50:47 2013 +0530 feature commit 05e96c39452126e9310e84203af72f141c37a493 Author: Habeeb Rahman <hrahman@apigee.com> Date: Tue Jun 18 13:46:35 2013 +0530 first commit (master)$ git log --oneline 70c1e30 feature 05e96c3 first commit
  • 22. git grep (master)$ git grep hello hello.txt:hello world new.txt:hello everyone
  • 23. git clone Local: git clone /path/to/repository Remote: git clone git://github.com/sample/test.git
  • 24. git help display help information about git $ git help help $ git help grep $ git help reset