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
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
Abdul 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
 

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 (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

GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji
3camp
 
slides.pdf
slides.pdfslides.pdf
slides.pdf
vidsvagi
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJug
Sé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

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
+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...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

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