SlideShare a Scribd company logo
git
Tips & Tricks
Wallace Reis | wreis
Tuesday, October 08, 2013
Best practices?
Tuesday, October 08, 2013
https://trac.dev.123people.com/trac/wiki/git/workflow
Tuesday, October 08, 2013
Tuesday, October 08, 2013
[alias]
st = status
ci = commit -v
addi = add --interactive
br = checkout -b
co = checkout
pick = cherry-pick -s
praise = blame -w
up = !git stash && git pull --
rebase && git submodule update &&
git stash apply
who = shortlog -se --
Tuesday, October 08, 2013
Find out wtf something
was done that way?
Tuesday, October 08, 2013
$ git blame -s Module.pm
Tuesday, October 08, 2013
892dc8d8 1) package Module;
892dc8d8 2) ...
892dc8d8 3) ...
Tuesday, October 08, 2013
$ git show 892dc8d8
Tuesday, October 08, 2013
Delete remote
branches?
Tuesday, October 08, 2013
$ git push origin :branch_name
Tuesday, October 08, 2013
Revert uncommitted
changes?
Tuesday, October 08, 2013
$ git checkout -- <filename>
or
$ git reset --hard HEAD
Tuesday, October 08, 2013
Revert a commit?
Tuesday, October 08, 2013
$ git revert 892dc8d8
Tuesday, October 08, 2013
And remove
untracked files?
Tuesday, October 08, 2013
$ git clean -n -d # dry run
then
$ git clean -d -f # “f” may not be
required
Tuesday, October 08, 2013
How to mangle the
last commit done?
Tuesday, October 08, 2013
$ git commit --amend
Tuesday, October 08, 2013
How about reverting
it?
Tuesday, October 08, 2013
$ git revert HEAD
Tuesday, October 08, 2013
Which changes will a
branch bring in the next
merge?
Tuesday, October 08, 2013
$ git log --stat master..integration
or
$ git cherry -v master integration
Tuesday, October 08, 2013
How about changes
since last
deployment?
Tuesday, October 08, 2013
$ git log --stat release-1.53..HEAD
or
$ git cherry -v release-1.53 HEAD
Tuesday, October 08, 2013
How about changes
since last pull?
Tuesday, October 08, 2013
$ git fetch origin
$ git log --stat master..origin/
master
or
$ git cherry -v master origin/
master
Tuesday, October 08, 2013
Which branches are
not merged yet...
Tuesday, October 08, 2013
...into integration
branch?
$ git branch --no-merged integration
Tuesday, October 08, 2013
Would like to see a file
some revisions ago?
Tuesday, October 08, 2013
$ git show HEAD~3:Module.pm
or
$ git show 892dc8d8:Module.pm
or
$ git show branch_name:Module.pm
Tuesday, October 08, 2013
Reorder, squash,
delete, or edit
commits
Tuesday, October 08, 2013
$ git rebase -i HEAD~4
Tuesday, October 08, 2013
pick dec6340 update plaxo and live tabs
pick 5e1adaf Update plaxo and live icons
pick 7f0473a Fix flickr icon
pick 0b04eda Added Vimeo tracking.
# Rebase b7722d5..0b04eda onto b7722d5
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x <cmd>, exec <cmd> = Run a shell command <cmd>, and stop if it fails
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
Tuesday, October 08, 2013
r dec6340 update plaxo and live tabs
f 5e1adaf Update plaxo and live icons
pick 0b04eda Added Vimeo tracking.
e 7f0473a Fix flickr icon
# Rebase b7722d5..0b04eda onto b7722d5
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x <cmd>, exec <cmd> = Run a shell command <cmd>, and stop if it fails
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
Tuesday, October 08, 2013
Recover lost commits
Tuesday, October 08, 2013
$ git reflog
Tuesday, October 08, 2013
cb462ba HEAD@{5}: checkout: moving from 154544202d4ff890a89ca4df30286d5c7edf0b39 to
master
1545442 HEAD@{6}: commit: Add foo to shared_components
e3456b3 HEAD@{7}: checkout: moving from cb462ba81c606f3e75d797712d9b49deddb442b0 to
e3456b3d337084136b5c95ddb7268d68bf428a8e
cb462ba HEAD@{8}: checkout: moving from e3456b3d337084136b5c95ddb7268d68bf428a8e to
cb462ba81c606f3e75d797712d9b49deddb442b0
e3456b3 HEAD@{9}: checkout: moving from master to
e3456b3d337084136b5c95ddb7268d68bf428a8e
Tuesday, October 08, 2013
merge
or
format-patch + am
Tuesday, October 08, 2013
Thank you!
Discussion?
Tuesday, October 08, 2013

More Related Content

PDF
git session --interactive
PDF
Git branching model_for_tap_team
PDF
Github integration-kostyasha
PDF
Get on with git
PDF
I love Automation
PDF
Loading...git
PDF
Essential git fu for tech writers
PPTX
Ohh shit git
git session --interactive
Git branching model_for_tap_team
Github integration-kostyasha
Get on with git
I love Automation
Loading...git
Essential git fu for tech writers
Ohh shit git

What's hot (11)

PDF
Git introduction
KEY
Git Distributed Version Control System
PDF
Null, the Abyss
PDF
もっとgit
KEY
Git Magic: Versioning Files like a Boss
PDF
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
PDF
Undoing Things in Git
ODP
Use of django at jolt online v3
PDF
git. WTF is it doing anyway?
PDF
Analysing Github events with Neo4j
PDF
Git introduction
Git Distributed Version Control System
Null, the Abyss
もっとgit
Git Magic: Versioning Files like a Boss
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
Undoing Things in Git
Use of django at jolt online v3
git. WTF is it doing anyway?
Analysing Github events with Neo4j
Ad

Viewers also liked (20)

PPTX
Challenges of Monetary Policy Communication
PPTX
Week3 intro to computer (history of comps, comps in everyday life)
PPTX
Getting into HTML
PDF
Trabalhe de casa, pergunte-me como!
PDF
Elasticsearch Quick Introduction
PPTX
Proceso de paz
PPTX
Boston elasticsearch meetup October 2012
PDF
PPT
Camtasia getting started guide
PPTX
Victimas del desplazamiento forzado
PPTX
Actividad 14
PPT
Ya soy grande
PDF
A reviravolta do desenvolvimento web
PDF
Artikel7 d06973bf5717bdc8687bcbdde31c4cb
PPTX
Higiene y seguridad industrial
PPTX
Proceso de paz
PPTX
Monetary_Policy_Target_Audience_Expanding_Reach_through_Tailored_Form_Content
PPT
My Presentation
PDF
European union: a quick explaination
PDF
Using media to_grow_your_business
Challenges of Monetary Policy Communication
Week3 intro to computer (history of comps, comps in everyday life)
Getting into HTML
Trabalhe de casa, pergunte-me como!
Elasticsearch Quick Introduction
Proceso de paz
Boston elasticsearch meetup October 2012
Camtasia getting started guide
Victimas del desplazamiento forzado
Actividad 14
Ya soy grande
A reviravolta do desenvolvimento web
Artikel7 d06973bf5717bdc8687bcbdde31c4cb
Higiene y seguridad industrial
Proceso de paz
Monetary_Policy_Target_Audience_Expanding_Reach_through_Tailored_Form_Content
My Presentation
European union: a quick explaination
Using media to_grow_your_business
Ad

Similar to Git - tips and tricks (20)

PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Git session Dropsolid.com
PPTX
Git and git workflow best practice
PPTX
PPTX
Git Memento of basic commands
PDF
GIT Basics
PPTX
Git walkthrough
PPTX
Git a stupid change tracker and persistent map.
PPTX
Working with Git
PPTX
Git-ing out of your git messes
PPTX
Git basics 2
PDF
Git tutorial
PPTX
Git presentation bixlabs
PDF
Atlassian git cheatsheet
PDF
Git walkthrough
PDF
Did you git yet?
PPTX
An introduction to Git
Techoalien git
Techoalien git
Techoalien git
Git session Dropsolid.com
Git and git workflow best practice
Git Memento of basic commands
GIT Basics
Git walkthrough
Git a stupid change tracker and persistent map.
Working with Git
Git-ing out of your git messes
Git basics 2
Git tutorial
Git presentation bixlabs
Atlassian git cheatsheet
Git walkthrough
Did you git yet?
An introduction to Git

Recently uploaded (20)

PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Getting Started with Data Integration: FME Form 101
PPT
What is a Computer? Input Devices /output devices
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
The various Industrial Revolutions .pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Hybrid model detection and classification of lung cancer
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
DP Operators-handbook-extract for the Mautical Institute
NewMind AI Weekly Chronicles – August ’25 Week III
Zenith AI: Advanced Artificial Intelligence
Hindi spoken digit analysis for native and non-native speakers
Chapter 5: Probability Theory and Statistics
Getting Started with Data Integration: FME Form 101
What is a Computer? Input Devices /output devices
cloud_computing_Infrastucture_as_cloud_p
Univ-Connecticut-ChatGPT-Presentaion.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
1 - Historical Antecedents, Social Consideration.pdf
The various Industrial Revolutions .pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Hybrid model detection and classification of lung cancer
Assigned Numbers - 2025 - Bluetooth® Document
Programs and apps: productivity, graphics, security and other tools
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx

Git - tips and tricks