SlideShare a Scribd company logo
1 of 39
Download to read offline
Git Playground
Shinho
Contents
Key concepts
Basic level
Advanced level
Additional tips that you don’t want (need) to use(know) YET
Git
Centralized Version Control
Distributed Version Control
Git commands
Key concept: Snapshots
Git keeps "snapshots" of the entire state of the project.
Key concept: Repository
Between repositories
● Clone
● Push
● Fetch, Pull
Within a repository
● Commit
● Merge
● ...other actions
Basic: Within a Repo
Key concept: Commit
Act of creating a snapshot.
Key concept: Branch
git checkout -b branch_name
git branch branch_name
Key concept: HEAD
● Symbolic name for the currently checked out commit.
● Detaching HEAD from branch is possible.
Key concept: HEAD
● symbolic name for the currently checked out commit
git checkout C4
git checkout bugFix
Branch: Merge
git merge bugFix
Branch: Merge
git checkout bugFix
git merge master
Branch: Rebase
git rebase master
Branch: Rebase
git rebase bugFix
Basic: Between Repos
Key concept: Clone
Git clone remote_server_repository_url
Key concept: Fetch
Key concept: Pull = Fetch + Merge
Key concept: Pull
cloned 2 commits on remote master
1 commit on local master Git pull
Key concept: Push
Advanced:
Working Together
Pull Request
Failed Push
git pull
git push
git fetch
git rebase o/master
git push
Or
git pull --rebase
git push
git push >>> fails!!
Cherry-pick
git cherry-pick C2 C4
Merge conflict
Merge conflict
Advanced:
Nice and neat history
Stash
DEMO
Use git stash when you want to record the current state of the
working directory and the index, but want to go back to a clean
working directory.
Personally, I don’t use stash that much, instead of this I commit
current changes temporarily and rebase or reset later.
Reset & Revert
git reset HEAD~1
git revert HEAD
Interactive rebase (change the commits order)
git rebase -i HEAD~4
pick
Some problematic cases
● You have committed a change (or changes) to a branch, but the commit(s)
should be in another branch.
○ The branch history is only in LOCAL
○ The branch history is already pushed to REMOTE
● You want to split up current branch state into two or three different branches.
○ The branch history is only in LOCAL
○ The branch history is already pushed to REMOTE
Additional tips that you
don’t want (need) to
use(know) YET
Clean up merged branches on your local repo
git branch --merged | egrep -v "(^*|master|dev)" | xargs git branch -d
Rewriting histories (squash & rebase)
https://confluence.atlassian.com/bitbucketserver/pull-request-merge-strategies-844499235.html
Fork and Pull Request
References
https://www.slideshare.net/HubSpot/git-101-git-and-github-for-beginners
https://courses.cs.washington.edu/courses/cse403/13au/lectures/git.ppt.pdf
https://learngitbranching.js.org/
https://blog.carbonfive.com/2017/08/28/always-squash-and-rebase-your-git-commi
ts/
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
Cheat sheet
If you want to use alias for git, install zsh and set plugin for git.
e.g. ‘ga’ instead of ‘git add’, ‘gp’ for ‘git push’...,
● Install ZSH: https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH
● Install Oh-My-ZSH: sh -c "$(curl -fsSL
https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/inst
all.sh)"
● Set plugin: https://github.com/robbyrussell/oh-my-zsh#plugins
If you want to add additional alias for yourself.
● vi ~/.zshrc
● Put this on any line (usually the last line)
○ alias some_shorten_command=”some full command”
○ E.g. alias gitr="git branch --merged | egrep -v "(^*|master|dev)" | xargs git branch -d"
■ Then you can use `gitr` on your terminal.
Cheat sheet
Description Command using alias Full command
Add changed files to staging ga . git add .
Commit staged files with message gc -m 'some message' git commit -m 'some message'
Add changed files to staging and commit with
message. but newly created files are not affected
gc -a -m 'some message' git commit -a -m 'some message'
Create branch gco -b 'branch name' git checkout -b 'branch name'
Change branch gco 'branch name' git checkout 'branch name'
Reset last 2 commits, but keeping the changes N/A git reset --soft HEAD~2
Pull the latest changes of a branch gco 'branch name'
gl
gco 'branch name'
git pull
Push the commits to remote server gp git push
Change to master branch gcm git checkout master
Merge master branch of remote server to current
branch
gmom git merge origin/master
Clean up already merged branches gcm
gitr **
** if you added alias of this command by the
instruction on slide 38, you can use the short
command.
git checkout master
git branch --merged | egrep -v "(^*|master|dev)" |
xargs git branch -d

More Related Content

What's hot (20)

Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheet
 
Git
GitGit
Git
 
Introduction into Git
Introduction into GitIntroduction into Git
Introduction into Git
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
 
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 introduction
Git introductionGit introduction
Git introduction
 
Git commands
Git commandsGit commands
Git commands
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Basic Git
Basic GitBasic Git
Basic Git
 
Git basics 2
Git basics 2Git basics 2
Git basics 2
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Git
GitGit
Git
 
DrupalCafe5 VCS
DrupalCafe5 VCSDrupalCafe5 VCS
DrupalCafe5 VCS
 
Basic principles of Git
Basic principles of GitBasic principles of Git
Basic principles of Git
 
Git github
Git githubGit github
Git github
 
Git SCM
Git SCMGit SCM
Git SCM
 

Similar to Honestly Git Playground 20190221

Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Git Intermediate Course
Git Intermediate CourseGit Intermediate Course
Git Intermediate CourseAli Abbasi
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)Carlos Duarte do Nascimento
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Getting some Git
Getting some GitGetting some Git
Getting some GitBADR
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 

Similar to Honestly Git Playground 20190221 (20)

Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git Intermediate Course
Git Intermediate CourseGit Intermediate Course
Git Intermediate Course
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Git basic
Git basicGit basic
Git basic
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Git tips
Git tipsGit tips
Git tips
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Session git
Session gitSession git
Session git
 

Recently uploaded

SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 

Recently uploaded (20)

SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

Honestly Git Playground 20190221