SlideShare a Scribd company logo
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

PDF
Git Rebase vs Merge
PPTX
Git for beginner
PDF
Undoing Things in Git
PPTX
git - the basics
PDF
Git for the absolute beginners
PDF
GIT - GOOD PRACTICES
PDF
Github git-cheat-sheet
Git Rebase vs Merge
Git for beginner
Undoing Things in Git
git - the basics
Git for the absolute beginners
GIT - GOOD PRACTICES
Github git-cheat-sheet

What's hot (20)

PDF
Atlassian git cheatsheet
PPTX
PPTX
Introduction into Git
PDF
Git - Get Ready To Use It
PPTX
Techoalien git
PDF
Git Developer Cheatsheet
PPTX
Git-ing out of your git messes
PDF
Git introduction
PPTX
Git commands
PDF
Git-ing out of your git messes - Fluent Conf 2017
PPTX
01 - Git vs SVN
KEY
Basic Git
PPTX
Git basics 2
PDF
Git tutorial
ODP
The Fundamentals of Git
PDF
ODP
DrupalCafe5 VCS
PPTX
Basic principles of Git
DOCX
Git github
PDF
Atlassian git cheatsheet
Introduction into Git
Git - Get Ready To Use It
Techoalien git
Git Developer Cheatsheet
Git-ing out of your git messes
Git introduction
Git commands
Git-ing out of your git messes - Fluent Conf 2017
01 - Git vs SVN
Basic Git
Git basics 2
Git tutorial
The Fundamentals of Git
DrupalCafe5 VCS
Basic principles of Git
Git github
Ad

Similar to Honestly Git Playground 20190221 (20)

PPTX
Git walkthrough
PDF
Git of every day
PDF
Git training v10
PDF
Advanced Git Tutorial
PDF
Git and github 101
PDF
Pro git - grasping it conceptually
ODP
Git presentation
PPTX
An introduction to Git
PPTX
Techoalien git
PPTX
Techoalien git
PDF
test
PDF
Techmoneyguide
PDF
Git cheat-sheet-education
PDF
Git cheat-sheet-education
PDF
Git training cheat sheet
PPTX
Intro to git and git hub
PDF
Advanced Git - Functionality and Features
PDF
Git 入门与实践
PDF
Git walkthrough
Git of every day
Git training v10
Advanced Git Tutorial
Git and github 101
Pro git - grasping it conceptually
Git presentation
An introduction to Git
Techoalien git
Techoalien git
test
Techmoneyguide
Git cheat-sheet-education
Git cheat-sheet-education
Git training cheat sheet
Intro to git and git hub
Advanced Git - Functionality and Features
Git 入门与实践
Ad

Recently uploaded (20)

DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
Cost to Outsource Software Development in 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
assetexplorer- product-overview - presentation
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Monitoring Stack: Grafana, Loki & Promtail
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Autodesk AutoCAD Crack Free Download 2025
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
17 Powerful Integrations Your Next-Gen MLM Software Needs
Cost to Outsource Software Development in 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
assetexplorer- product-overview - presentation
Odoo Companies in India – Driving Business Transformation.pdf
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Complete Guide to Website Development in Malaysia for SMEs
wealthsignaloriginal-com-DS-text-... (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Digital Systems & Binary Numbers (comprehensive )
Advanced SystemCare Ultimate Crack + Portable (2025)

Honestly Git Playground 20190221