SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
Git, The Good Stuff
Phil Palmieri
What We Are Covering
- Git Log
- Rebasing
- Squashing
- Cherry-Picking
- Patch Files
- Reverting and Oh S!#t now what do I do?
Anatomy of the log
- %> git log
- Every commit has a unique hash
- Every hash has a
- diff / files
- date
- author
- message
Git Log Options
- Git log any branch by appending “git log [branch name]”
- %> git log --stat (shows files)
- --since/after=[date]
- --until/before=[date]
- --grep=[regex]
- --graph (pretty graph)
Git Log Format
- %> git log --format=[oneline|short|medium|full]
- %> git log --format=”custom %h formatting”
- %h [short hash]
- %an [author name]
- %ar [date relative]
- %C [color]
full list at https://git-scm.com/docs/git-log
Viewing a commit / hash
%> git show [hash]
Rebasing
%> git rebase [branch]
re-stacking the deck
3
1 - 2
1 2
1 2
2
2
2
3
1
1
1
Combining (squashing) commits
%> git rebase -i HEAD~2
- will rebase interactive the last 2 commits
- change hash to ‘s’ to squash multiple commits
- update messages
3.2
3.1
3
2
1
3
2
1
Cherry-Picking
%> git cherry-pick [hash]
creates a copy of a commit on one branch to another.
- very good for copying code to a Q/A server
Create a ‘Simple’ Patch File
%> git show [hash1] > ~/mypatch.patch
%> git show [hash2] >> ~/mypatch.patch (append)
%> git apply ~/mypatch.patch
Undo / Oh S#%t button
%> git reset --hard HEAD
-----------------------------------------------
%> git reset --hard HEAD^^^^^^^ (rollback a few commits)
%> git pull
Undo Your Commit
%> git revert [hash]
Did your code/commit break something - undo it.
note: You can revert a revert to put it back
Git Blame (who wrote that code?)
%> git blame [file]
Will show you who changed each line of the file

Weitere ähnliche Inhalte

Andere mochten auch

Presentazione Gruppo 11
Presentazione Gruppo 11Presentazione Gruppo 11
Presentazione Gruppo 11
Marco Lusardi
 
Presentación netiketa 2012
Presentación netiketa 2012Presentación netiketa 2012
Presentación netiketa 2012
Daliaaragon
 
Panic and run or plan and respond
Panic and run or plan and respondPanic and run or plan and respond
Panic and run or plan and respond
Matt Stein
 

Andere mochten auch (12)

Practica 25
Practica 25Practica 25
Practica 25
 
Ponte Sobre o Rio Capivari
Ponte Sobre o Rio CapivariPonte Sobre o Rio Capivari
Ponte Sobre o Rio Capivari
 
Presentazione Gruppo 11
Presentazione Gruppo 11Presentazione Gruppo 11
Presentazione Gruppo 11
 
Caso Estudio Sbm 25032010
Caso Estudio  Sbm 25032010Caso Estudio  Sbm 25032010
Caso Estudio Sbm 25032010
 
Presentación netiketa 2012
Presentación netiketa 2012Presentación netiketa 2012
Presentación netiketa 2012
 
Panic and run or plan and respond
Panic and run or plan and respondPanic and run or plan and respond
Panic and run or plan and respond
 
Research maga
Research magaResearch maga
Research maga
 
Cambios tecnologicos
Cambios tecnologicosCambios tecnologicos
Cambios tecnologicos
 
Hr's strategic shift -how to leverage hr technology to drive business results
Hr's strategic shift -how to leverage hr technology to drive business resultsHr's strategic shift -how to leverage hr technology to drive business results
Hr's strategic shift -how to leverage hr technology to drive business results
 
Roskildefestival big data
Roskildefestival big dataRoskildefestival big data
Roskildefestival big data
 
Учебная игра «Контрнаступление под Москвой»
Учебная игра «Контрнаступление под Москвой»Учебная игра «Контрнаступление под Москвой»
Учебная игра «Контрнаступление под Москвой»
 
Histology of trachea and lung
Histology of trachea and lungHistology of trachea and lung
Histology of trachea and lung
 

Ähnlich wie Git, The Good Stuff

Git Introduction
Git IntroductionGit Introduction
Git Introduction
Gareth Hall
 

Ähnlich wie Git, The Good Stuff (20)

Git Basic
Git BasicGit Basic
Git Basic
 
Git
GitGit
Git
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
Finding Things in Git
Finding Things in GitFinding Things in Git
Finding Things in Git
 
git - the basics
git - the basicsgit - the basics
git - the basics
 
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 internals
Git internalsGit internals
Git internals
 
DrupalCafe5 VCS
DrupalCafe5 VCSDrupalCafe5 VCS
DrupalCafe5 VCS
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git
GitGit
Git
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
git. WTF is it doing anyway?
git. WTF is it doing anyway?git. WTF is it doing anyway?
git. WTF is it doing anyway?
 
An introduction to Git with Atlassian Suite
An introduction to Git with Atlassian SuiteAn introduction to Git with Atlassian Suite
An introduction to Git with Atlassian Suite
 
Git, Beginner to Advanced Survey
Git, Beginner to Advanced SurveyGit, Beginner to Advanced Survey
Git, Beginner to Advanced Survey
 
Managing e commerce systems codebase with git
Managing e commerce systems codebase with gitManaging e commerce systems codebase with git
Managing e commerce systems codebase with git
 
maksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your cimaksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your ci
 
Tech thursdays / GIT
Tech thursdays / GITTech thursdays / GIT
Tech thursdays / GIT
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Git, The Good Stuff

  • 1. Git, The Good Stuff Phil Palmieri
  • 2. What We Are Covering - Git Log - Rebasing - Squashing - Cherry-Picking - Patch Files - Reverting and Oh S!#t now what do I do?
  • 3. Anatomy of the log - %> git log - Every commit has a unique hash - Every hash has a - diff / files - date - author - message
  • 4. Git Log Options - Git log any branch by appending “git log [branch name]” - %> git log --stat (shows files) - --since/after=[date] - --until/before=[date] - --grep=[regex] - --graph (pretty graph)
  • 5. Git Log Format - %> git log --format=[oneline|short|medium|full] - %> git log --format=”custom %h formatting” - %h [short hash] - %an [author name] - %ar [date relative] - %C [color] full list at https://git-scm.com/docs/git-log
  • 6. Viewing a commit / hash %> git show [hash]
  • 7. Rebasing %> git rebase [branch] re-stacking the deck 3 1 - 2 1 2 1 2 2 2 2 3 1 1 1
  • 8. Combining (squashing) commits %> git rebase -i HEAD~2 - will rebase interactive the last 2 commits - change hash to ‘s’ to squash multiple commits - update messages 3.2 3.1 3 2 1 3 2 1
  • 9. Cherry-Picking %> git cherry-pick [hash] creates a copy of a commit on one branch to another. - very good for copying code to a Q/A server
  • 10. Create a ‘Simple’ Patch File %> git show [hash1] > ~/mypatch.patch %> git show [hash2] >> ~/mypatch.patch (append) %> git apply ~/mypatch.patch
  • 11. Undo / Oh S#%t button %> git reset --hard HEAD ----------------------------------------------- %> git reset --hard HEAD^^^^^^^ (rollback a few commits) %> git pull
  • 12. Undo Your Commit %> git revert [hash] Did your code/commit break something - undo it. note: You can revert a revert to put it back
  • 13. Git Blame (who wrote that code?) %> git blame [file] Will show you who changed each line of the file