SlideShare a Scribd company logo
1 of 43
Download to read offline
Did you            yet?Did you            yet?
“ Git  is a British English slang roughly
equivalent to "unpleasant person".
1 . 1
ChangelogChangelog
v 1.0.1
Basic git concept and commands
git flow concept
1 . 2
Design GoalDesign Goal
Git is an open source,  distributed  version
control system designed to be  fast and
branching
Decentralized
vs Centralized (SVN / Perforce / CVS)
Suitable for fast development of multiple branch in
parallel
Git Generally DOES NOT delete data
Git Generally append data in version tree.
Recovering deleted data could be tricky
2 . 1
Work FlowWork Flow
Index
2 . 2
Pros / ConsPros / Cons
Centralized Decentralized
Concurrent Access
Control
File Locking N.A; Manual
intervention is required
to resolve the conflict.
Offline Development Unable to submit
changelist; create a tag /
branch. 
Able to commit to local
repository
Remote Server One Centralized server multiple remote repo
2 . 3
Pros / ConsPros / Cons
Centralized Decentralized
Concurrent Access
Control
File Locking N.A; Manual
intervention is required
to resolve the conflict.
Offline Development Unable to submit
changelist; create a tag /
branch. 
Able to commit to local
repository
Remote Server One Centralized server multiple remote repo
2 . 3
Pros / ConsPros / Cons
Centralized Decentralized
Concurrent Access
Control
File Locking N.A; Manual
intervention is required
to resolve the conflict.
Offline Development Unable to submit
changelist; create a tag /
branch. 
Able to commit to local
repository
Remote Server One Centralized server multiple remote repo
2 . 3
Git ObjectsGit Objects
 $ ll .git/
4096 Apr 7 2018 branches/
528 Nov 9 17:32 COMMIT_EDITMSG
284 Nov 8 20:48 config
73 Apr 7 2018 description
272 Jun 18 00:04 FETCH_HEAD
23 Nov 9 12:35 HEAD
4096 Apr 7 2018 hooks/
16153 Nov 9 17:31 index
4096 Apr 7 2018 info/
4096 Apr 7 2018 logs/
4096 Aug 15 22:56 objects/
41 Nov 8 20:49 ORIG_HEAD
107 Apr 7 2018 packed-refs
4096 Nov 6 14:31 refs/
3 . 1
CommitCommit
A.k.a. Ref / Reference
Alias to a hash (SHA-1) commit hash
See the SHA-1 commit hashes
$ git log
commit 059806c1e05ed7a3a387da16d05844f63c47251a
Author: Author Name <Author Email>
Date: Fri Nov 9 17:31:31 2018 +0800
Commit Title
Commit Description
commit 91e622c61f99f24dbda741050e251837a643f6c9
Author: Michael Fong <mcfong.open@gmail.com>
Date: Thu Nov 8 20:26:33 2018 +0800
Another Commit
3 . 2
HEADHEAD
HEAD file is a symbolic ref for the current branch
$ tree .git/refs/heads/
.git/refs/heads/
├── ConnectionPool
├── LocalhostJmxConnectorServerProxyDemo
├── master
├── RACBenchmark
├── string-builder-perf-death-match
├── study-fadvise-effect
├── tuneWarmUpIteration
└── unintentional-obj-retension
0 directories, 8 files
$ cat .git/refs/heads/master
059806c1e05ed7a3a387da16d05844f63c47251a
Uses HEAD file to store latest commit info of the
branch
3 . 3
BasicBasic
CommandsCommands
4 . 1
Initialize Git SettingInitialize Git Setting
User Information
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
Editor Information
# Set default editor to vim
$ git config --global core.editor vim
# Set default editor to emacs
$ git config --global core.editor emacs
List current settings
$ git config --list
user.email=mcfong.open@gmail.com
user.name=Michael Fong
core.editor=vim
...
4 . 2
Clone RepositoryClone Repository
$ git clone https://github.com/<username>/<project>
Clone repository via Https
$ git clone ssh://github.com/<username>/<project>
Clone repository via SSH
Show current repository status
$ git status
On branch <local-repo>
Your branch is up-to-date with <remote-repo>.
nothing to commit, working directory clean
<If there is (new) file different from current ver,
they will appear here>
# Diff against local workspace and index
$ git diff
4 . 3
Commit ChangesCommit Changes
# add new files
$ git add 1.file
# add by pattern
$ git add *.file
# add by everything under directory
$ git add ./
$ git add -all
# remove file from tracking
$ git rm file.py
# Diff against local repo and index
$ git diff --cached
Staging Changes
Update to local Staging Area / Index
Commit Changes
Update to local repo
# Enter commit commit description in default editor
$ git commit
# alternatively, one command commit
$ git commit -am "Enter your commit description"
4 . 4
Branch ManagementBranch Management
# create a new branch
$ git checkout master
$ git branch new-branch
# Alternatively, create a new branch from remote-repo/remote-branch
$ git checkout <remote-repo>/<remote-branch> -b <local-branch>
$ git checkout origin/master -b new-branch
#Create a new branch from tag
$ git checkout tags/<tag-name> -b new-branch
Create a new local branch
Switch to existing local branch
List all Branches
$ git checkout new-branch
# (noarg - local branch; -r remote branch; -a all branch)
$ git branch -av
Delete Branch
# Delete local repository
$ git branch -d new-branch
# Delete local repository by force
$ git branch -D new-branch
# Delete a branch from remote repository
$ git push <remote-repo> :<branch-name> 4 . 5
Remote CommandRemote Command
# Add a new remote repo
$ git remote add origin <GIT_URL_HTTPS_or_SSH>
# Update an existing remote repo
$ git remote update origin <GIT_URL_HTTPS_or_SSH>
Push to remote repo:branch
# Fetch & Merge
$ git pull
# Fetch from remote repo
$ git fetch origin
# Merge from remote branch master
$ git merge origin master
Pull from remote repository
Add / Update a remote repository
# push to remote-repo (origin) / remote-branch (master)
$ git push <remote-repo> <local-branch>:<remote-branch>
$ git push origin master:master
$ git push origin master
$ git push origin new-branch:new-branch
4 . 6
(Local Branch) Merge Strategy I(Local Branch) Merge Strategy I
Fast Forward Merge
When the merge resolves as a fast-forward, only
update the branch pointer, without creating a
merge commit.
Default merge strategy
$ git checkout master
$ git merge new-branch (--ff)
4 . 7
(Local Branch) Merge Strategy II(Local Branch) Merge Strategy II
Non Fast Forward Merge
Create a merge commit
$ git checkout master
$ git merge new-branch --no-ff
4 . 8
(Local Branch) Merge Strategy II(Local Branch) Merge Strategy II
Merge Commit
$ git checkout -b new-branch
$ git commit -am 'commit'
$ git checkout master
$ git merge new-branch --no-ff
$ git log
commit 33a935fb06182ba9c6868a9bf85efe7c2e5770f3
Merge: 1d9f153 efd5daa
Author: XXX
Date: Mon Nov 26 11:41:25 2018 +0800
Merge branch 'new-branch'
commit efd5daabfc1d4366f197dc71c3edfd251b0396d0
Author: XXX
Date: Mon Nov 26 11:41:00 2018 +0800
commit
2018-11-26 11:41 Michael Fong M─┐ [master] Merge branch 'new-branch'
2018-11-26 11:41 Michael Fong │ o commit
2018-11-21 15:58 Michael Fong o─┘ {origin/master} {origin/HEAD}
Branching graph
4 . 9
(Remote Branch) Merge(Remote Branch) Merge
Merge between two branch on remote repository
Github: Pull Request
Gitlab: Merge Request
Non fast forward merge
Default strategy for merging PR
Usually configurableg
4 . 10
Merge StrategyMerge Strategy
Log Branch Graph
Fast Forward Clean Less intuitive
No Fast Forward Merge commit More intuitive
4 . 11
Merge ConflictsMerge Conflicts
Manual intervention is required.
 
After self correction is done; add and commit the
conflict files.
$ git add index.html
$ git commit
4 . 12
Rebase IRebase I
Moving a branch onto a new base commit
Rebasing onto master will take all commits from
master and apply your branch commits on top one by
one.
Later could combine with merge to master
4 . 13
Rebase IIRebase II
If combined with squash, there will possibly be only
one commit.
4 . 14
Squash ISquash I
squash is a mechanism to consolidate multiple
commit into one.
It comes with rebase / merge command
4 . 15
Squash IISquash II
pick commit1 (528f601)
squash  commit2 (a96173c)
edit commit3 (eadd9c2)
4 . 16
Squash IIISquash III
Squashing commit 2 into commit 1
4 . 17
Squash IVSquash IV
Edit commit 3
4 . 18
Cherry PickCherry Pick
Given one or more existing commits, apply the change
each one introduces, recording a new commit for
each.
$ git cherry-pick C2 C4
4 . 19
TagTag
Annotation to represent release
Create a tag
List all tags
$ git tag -a <tag-name> -m 'description'
$ git push <remote-repo> <tag-name>
$ git tag -l
Show tag metadata
$ git show <tag-name>
Delete a tag
$ git tag -d <tag-name>
$ git push <remote-repo> <tag-name>
4 . 20
RecoverRecover
CommandsCommands
5 . 1
StashStash
How to save unfinished implementation temporarily?
Save the current state of work.
# Save current work, and rollback to HEAD keep current work space clean
$ git stash -u
# Reload latest stash record
$ git stash pop
# List stash record
$ git stash list
5 . 2
Undo Commit IUndo Commit I
$ git reset --soft HEAD~1
$ git diff --cached
$ git reset HEAD~1
$ git diff
$ git reset --hard HEAD~1
Reset current HEAD to the specific state
Changes are UNSTAGED
Changes are STAGED 
Changes are REMOVED from log
5 . 3
Undo Commit IIUndo Commit II
$ git checkout path/to/filename
$ git revert commit-hash
Reverts a commit with another commit 
 Restores the file to the latest version
in HEAD, changes are dropped
5 . 4
Reference LogReference Log
Historical records when the tips of branches and other
references were updated in the LOCAL repository.
Helpful when you want to look up historical commit
$ git reflog
Maybe your last resort to undo bad commit
Use at your RISK!
$ git reset --hard HEAD@{n}
5 . 5
Bash Alias IBash Alias I
# Nice format for `git log`
alias git.log="git log --graph --abbrev-commit --decorate --
format=format:'%C(bold blue)%h%C(reset) - %C(bold
cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)
(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n''         
%C(white)%s%C(reset)%n''          %C(dim white)- %an <%ae>
%C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)' --all"
* 059806c - Fri, 9 Nov 2018 17:31:31 +0800 (2 days ago) (committed: Fri, 9 Nov 2018 17:31:31 +080
| Add unit test to ByteBuf
| - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail.c
| * f5832fa - Fri, 9 Nov 2018 12:35:40 +0800 (2 days ago) (committed: Fri, 9 Nov 2018 12:35:40 +0
| | squash
| | - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail
| * f5f556a - Tue, 6 Nov 2018 19:54:47 +0800 (5 days ago) (committed: Thu, 8 Nov 2018 20:49:30 +0
|/ Add fadvise64
| - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail
* 91e622c - Thu, 8 Nov 2018 20:26:33 +0800 (3 days ago) (committed: Thu, 8 Nov 2018 20:42:14 +080
| Copy libnative-utility.so to target/classes for java-jni
| - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail.c
* 794bf26 - Wed, 7 Nov 2018 16:18:03 +0800 (4 days ago) (committed: Thu, 8 Nov 2018 00:45:32 +080
5 . 6
tigtig
Installation
$ sudo apt-get install tig
log
$ tig log
“ ncurses-based text-mode interface for git.
status
$ tig status
5 . 7
Branching BestBranching Best
PracticePractice
6 . 1
ProblemsProblems
Everyone has a copy.
Unfortunately, NOT the same copy!
Which master is more up to date?
Requiring
Discipline
Methodology
6 . 2
Ref
Git Flow MethodologyGit Flow Methodology
6 . 3
Branching ModelsBranching Models
master  - ONE true MASTER
develop
feature
Feature branches typically exist in
developer repos only, not in origin
release
Release branches support preparation
of a new production release.
hot-fix
 When a critical bug in a production
version must be resolved
immediately, a hotfix branch may be
branched off from the corresponding
tag on the master branch that marks
the production version.
6 . 4
ToolTool
Provide high level operation
github/git-flow/
Git Flow cheatsheet
6 . 5
ReferenceReference
Linux Travolds on git
Git-Basics
Learn How to Git
tig
https://www.youtube.com/embed/4XpnKHJ
Aok8?enablejsapi=1
7

More Related Content

What's hot

Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015mwrather
 
Git Terminologies
Git TerminologiesGit Terminologies
Git TerminologiesYash
 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...SlideTeam
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentationTerry Wang
 
Git Introduction
Git IntroductionGit Introduction
Git IntroductionGareth Hall
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...Edureka!
 
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 GitE Carter
 
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
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 

What's hot (20)

Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...
 
Git
GitGit
Git
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
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
 
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
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
 
Git Basic
Git BasicGit Basic
Git Basic
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 

Similar to Did you git yet?

Similar to Did you git yet? (20)

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-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Git cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdfGit cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdf
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221
 
Git basics
Git basicsGit basics
Git basics
 
Git
GitGit
Git
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Get going with_git_ppt
Get going with_git_pptGet going with_git_ppt
Get going with_git_ppt
 
Git training cheat sheet
Git training cheat sheetGit training cheat sheet
Git training cheat sheet
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
 
git internals
git internalsgit internals
git internals
 
Gittalk
GittalkGittalk
Gittalk
 
Git
GitGit
Git
 
Git
GitGit
Git
 
Git Tutorial Yang Yang
Git Tutorial Yang YangGit Tutorial Yang Yang
Git Tutorial Yang Yang
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 

Recently uploaded (20)

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 

Did you git yet?

  • 1. Did you            yet?Did you            yet? “ Git  is a British English slang roughly equivalent to "unpleasant person". 1 . 1
  • 2. ChangelogChangelog v 1.0.1 Basic git concept and commands git flow concept 1 . 2
  • 3. Design GoalDesign Goal Git is an open source,  distributed  version control system designed to be  fast and branching Decentralized vs Centralized (SVN / Perforce / CVS) Suitable for fast development of multiple branch in parallel Git Generally DOES NOT delete data Git Generally append data in version tree. Recovering deleted data could be tricky 2 . 1
  • 5. Pros / ConsPros / Cons Centralized Decentralized Concurrent Access Control File Locking N.A; Manual intervention is required to resolve the conflict. Offline Development Unable to submit changelist; create a tag / branch.  Able to commit to local repository Remote Server One Centralized server multiple remote repo 2 . 3
  • 6. Pros / ConsPros / Cons Centralized Decentralized Concurrent Access Control File Locking N.A; Manual intervention is required to resolve the conflict. Offline Development Unable to submit changelist; create a tag / branch.  Able to commit to local repository Remote Server One Centralized server multiple remote repo 2 . 3
  • 7. Pros / ConsPros / Cons Centralized Decentralized Concurrent Access Control File Locking N.A; Manual intervention is required to resolve the conflict. Offline Development Unable to submit changelist; create a tag / branch.  Able to commit to local repository Remote Server One Centralized server multiple remote repo 2 . 3
  • 8. Git ObjectsGit Objects  $ ll .git/ 4096 Apr 7 2018 branches/ 528 Nov 9 17:32 COMMIT_EDITMSG 284 Nov 8 20:48 config 73 Apr 7 2018 description 272 Jun 18 00:04 FETCH_HEAD 23 Nov 9 12:35 HEAD 4096 Apr 7 2018 hooks/ 16153 Nov 9 17:31 index 4096 Apr 7 2018 info/ 4096 Apr 7 2018 logs/ 4096 Aug 15 22:56 objects/ 41 Nov 8 20:49 ORIG_HEAD 107 Apr 7 2018 packed-refs 4096 Nov 6 14:31 refs/ 3 . 1
  • 9. CommitCommit A.k.a. Ref / Reference Alias to a hash (SHA-1) commit hash See the SHA-1 commit hashes $ git log commit 059806c1e05ed7a3a387da16d05844f63c47251a Author: Author Name <Author Email> Date: Fri Nov 9 17:31:31 2018 +0800 Commit Title Commit Description commit 91e622c61f99f24dbda741050e251837a643f6c9 Author: Michael Fong <mcfong.open@gmail.com> Date: Thu Nov 8 20:26:33 2018 +0800 Another Commit 3 . 2
  • 10. HEADHEAD HEAD file is a symbolic ref for the current branch $ tree .git/refs/heads/ .git/refs/heads/ ├── ConnectionPool ├── LocalhostJmxConnectorServerProxyDemo ├── master ├── RACBenchmark ├── string-builder-perf-death-match ├── study-fadvise-effect ├── tuneWarmUpIteration └── unintentional-obj-retension 0 directories, 8 files $ cat .git/refs/heads/master 059806c1e05ed7a3a387da16d05844f63c47251a Uses HEAD file to store latest commit info of the branch 3 . 3
  • 12. Initialize Git SettingInitialize Git Setting User Information $ git config --global user.name "John Doe" $ git config --global user.email johndoe@example.com Editor Information # Set default editor to vim $ git config --global core.editor vim # Set default editor to emacs $ git config --global core.editor emacs List current settings $ git config --list user.email=mcfong.open@gmail.com user.name=Michael Fong core.editor=vim ... 4 . 2
  • 13. Clone RepositoryClone Repository $ git clone https://github.com/<username>/<project> Clone repository via Https $ git clone ssh://github.com/<username>/<project> Clone repository via SSH Show current repository status $ git status On branch <local-repo> Your branch is up-to-date with <remote-repo>. nothing to commit, working directory clean <If there is (new) file different from current ver, they will appear here> # Diff against local workspace and index $ git diff 4 . 3
  • 14. Commit ChangesCommit Changes # add new files $ git add 1.file # add by pattern $ git add *.file # add by everything under directory $ git add ./ $ git add -all # remove file from tracking $ git rm file.py # Diff against local repo and index $ git diff --cached Staging Changes Update to local Staging Area / Index Commit Changes Update to local repo # Enter commit commit description in default editor $ git commit # alternatively, one command commit $ git commit -am "Enter your commit description" 4 . 4
  • 15. Branch ManagementBranch Management # create a new branch $ git checkout master $ git branch new-branch # Alternatively, create a new branch from remote-repo/remote-branch $ git checkout <remote-repo>/<remote-branch> -b <local-branch> $ git checkout origin/master -b new-branch #Create a new branch from tag $ git checkout tags/<tag-name> -b new-branch Create a new local branch Switch to existing local branch List all Branches $ git checkout new-branch # (noarg - local branch; -r remote branch; -a all branch) $ git branch -av Delete Branch # Delete local repository $ git branch -d new-branch # Delete local repository by force $ git branch -D new-branch # Delete a branch from remote repository $ git push <remote-repo> :<branch-name> 4 . 5
  • 16. Remote CommandRemote Command # Add a new remote repo $ git remote add origin <GIT_URL_HTTPS_or_SSH> # Update an existing remote repo $ git remote update origin <GIT_URL_HTTPS_or_SSH> Push to remote repo:branch # Fetch & Merge $ git pull # Fetch from remote repo $ git fetch origin # Merge from remote branch master $ git merge origin master Pull from remote repository Add / Update a remote repository # push to remote-repo (origin) / remote-branch (master) $ git push <remote-repo> <local-branch>:<remote-branch> $ git push origin master:master $ git push origin master $ git push origin new-branch:new-branch 4 . 6
  • 17. (Local Branch) Merge Strategy I(Local Branch) Merge Strategy I Fast Forward Merge When the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. Default merge strategy $ git checkout master $ git merge new-branch (--ff) 4 . 7
  • 18. (Local Branch) Merge Strategy II(Local Branch) Merge Strategy II Non Fast Forward Merge Create a merge commit $ git checkout master $ git merge new-branch --no-ff 4 . 8
  • 19. (Local Branch) Merge Strategy II(Local Branch) Merge Strategy II Merge Commit $ git checkout -b new-branch $ git commit -am 'commit' $ git checkout master $ git merge new-branch --no-ff $ git log commit 33a935fb06182ba9c6868a9bf85efe7c2e5770f3 Merge: 1d9f153 efd5daa Author: XXX Date: Mon Nov 26 11:41:25 2018 +0800 Merge branch 'new-branch' commit efd5daabfc1d4366f197dc71c3edfd251b0396d0 Author: XXX Date: Mon Nov 26 11:41:00 2018 +0800 commit 2018-11-26 11:41 Michael Fong M─┐ [master] Merge branch 'new-branch' 2018-11-26 11:41 Michael Fong │ o commit 2018-11-21 15:58 Michael Fong o─┘ {origin/master} {origin/HEAD} Branching graph 4 . 9
  • 20. (Remote Branch) Merge(Remote Branch) Merge Merge between two branch on remote repository Github: Pull Request Gitlab: Merge Request Non fast forward merge Default strategy for merging PR Usually configurableg 4 . 10
  • 21. Merge StrategyMerge Strategy Log Branch Graph Fast Forward Clean Less intuitive No Fast Forward Merge commit More intuitive 4 . 11
  • 22. Merge ConflictsMerge Conflicts Manual intervention is required.   After self correction is done; add and commit the conflict files. $ git add index.html $ git commit 4 . 12
  • 23. Rebase IRebase I Moving a branch onto a new base commit Rebasing onto master will take all commits from master and apply your branch commits on top one by one. Later could combine with merge to master 4 . 13
  • 24. Rebase IIRebase II If combined with squash, there will possibly be only one commit. 4 . 14
  • 25. Squash ISquash I squash is a mechanism to consolidate multiple commit into one. It comes with rebase / merge command 4 . 15
  • 26. Squash IISquash II pick commit1 (528f601) squash  commit2 (a96173c) edit commit3 (eadd9c2) 4 . 16
  • 27. Squash IIISquash III Squashing commit 2 into commit 1 4 . 17
  • 28. Squash IVSquash IV Edit commit 3 4 . 18
  • 29. Cherry PickCherry Pick Given one or more existing commits, apply the change each one introduces, recording a new commit for each. $ git cherry-pick C2 C4 4 . 19
  • 30. TagTag Annotation to represent release Create a tag List all tags $ git tag -a <tag-name> -m 'description' $ git push <remote-repo> <tag-name> $ git tag -l Show tag metadata $ git show <tag-name> Delete a tag $ git tag -d <tag-name> $ git push <remote-repo> <tag-name> 4 . 20
  • 32. StashStash How to save unfinished implementation temporarily? Save the current state of work. # Save current work, and rollback to HEAD keep current work space clean $ git stash -u # Reload latest stash record $ git stash pop # List stash record $ git stash list 5 . 2
  • 33. Undo Commit IUndo Commit I $ git reset --soft HEAD~1 $ git diff --cached $ git reset HEAD~1 $ git diff $ git reset --hard HEAD~1 Reset current HEAD to the specific state Changes are UNSTAGED Changes are STAGED  Changes are REMOVED from log 5 . 3
  • 34. Undo Commit IIUndo Commit II $ git checkout path/to/filename $ git revert commit-hash Reverts a commit with another commit   Restores the file to the latest version in HEAD, changes are dropped 5 . 4
  • 35. Reference LogReference Log Historical records when the tips of branches and other references were updated in the LOCAL repository. Helpful when you want to look up historical commit $ git reflog Maybe your last resort to undo bad commit Use at your RISK! $ git reset --hard HEAD@{n} 5 . 5
  • 36. Bash Alias IBash Alias I # Nice format for `git log` alias git.log="git log --graph --abbrev-commit --decorate -- format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan) (committed: %cD)%C(reset) %C(auto)%d%C(reset)%n''          %C(white)%s%C(reset)%n''          %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)' --all" * 059806c - Fri, 9 Nov 2018 17:31:31 +0800 (2 days ago) (committed: Fri, 9 Nov 2018 17:31:31 +080 | Add unit test to ByteBuf | - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail.c | * f5832fa - Fri, 9 Nov 2018 12:35:40 +0800 (2 days ago) (committed: Fri, 9 Nov 2018 12:35:40 +0 | | squash | | - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail | * f5f556a - Tue, 6 Nov 2018 19:54:47 +0800 (5 days ago) (committed: Thu, 8 Nov 2018 20:49:30 +0 |/ Add fadvise64 | - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail * 91e622c - Thu, 8 Nov 2018 20:26:33 +0800 (3 days ago) (committed: Thu, 8 Nov 2018 20:42:14 +080 | Copy libnative-utility.so to target/classes for java-jni | - Michael Fong <mcfong.open@gmail.com> (committer: Michael Fong <mcfong.open@gmail.c * 794bf26 - Wed, 7 Nov 2018 16:18:03 +0800 (4 days ago) (committed: Thu, 8 Nov 2018 00:45:32 +080 5 . 6
  • 37. tigtig Installation $ sudo apt-get install tig log $ tig log “ ncurses-based text-mode interface for git. status $ tig status 5 . 7
  • 39. ProblemsProblems Everyone has a copy. Unfortunately, NOT the same copy! Which master is more up to date? Requiring Discipline Methodology 6 . 2
  • 40. Ref Git Flow MethodologyGit Flow Methodology 6 . 3
  • 41. Branching ModelsBranching Models master  - ONE true MASTER develop feature Feature branches typically exist in developer repos only, not in origin release Release branches support preparation of a new production release. hot-fix  When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version. 6 . 4
  • 42. ToolTool Provide high level operation github/git-flow/ Git Flow cheatsheet 6 . 5
  • 43. ReferenceReference Linux Travolds on git Git-Basics Learn How to Git tig https://www.youtube.com/embed/4XpnKHJ Aok8?enablejsapi=1 7