SlideShare a Scribd company logo
1 of 16
Download to read offline
EFFECTIVE GIT
- TEJAS BUBANE
@tejasbubane
CONTENTS
▸ Git Philosophy
▸ Log tree
▸ Commits and Branches
▸ Rewriting History
▸ Merge vs Rebase vs Squash vs Cherry-pick
▸ Workflow
▸ Good Practices
THE GIT PHILOSOPHY
▸ Created by Linus Torvalds (after conflicts with Bitkeeper)
▸ For use in Linux kernel development
▸ Actually the Linux Philosophy
▸ Uses concepts from POSIX filesystem
▸ Stores snapshots not diffs
▸ All data stored in .git directory in delta compressed form
▸ Precise commands
▸ "Git" means an idiot (British Slang)
DISTRIBUTED!
▸ Everyone has local copy of entire history
▸ Can work entirely independently of others
▸ Even without internet
▸ Remote - URL to push the code to
▸ clone brings the project, creates origin and master
COMMIT OBJECTS
▸ One logical change in the codebase
▸ Message + Author (name, email) + Timestamp +
Snapshots of all files + Parent(s) reference
= checksum
▸ Everything is checksummed internally, each version of
each file has checksum
▸ Checksum - SHA-1, Unique, 40 character hex (20 bytes)
GIT HISTORY
▸ Commits have links with parent(s)
▸ Form a tree structure - Log tree - HISTORY
▸ Branches are nothing more than pointers to commit
objects
▸ Pointers change - refer to different object
▸ Remote and local branches
▸ HEAD - symbolic pointer pointing to current branch
MERGE
▸ git merge feature-branch
▸ Fast Forward
▸ Both commits are inline
▸ Just move the pointer to the next commit
▸ Non-fast-forward
▸ Commits not-inline
▸ Create a new snapshot and a merge commit
▸ Looks at nearest common parent to create new snapshot
REWRITING HISTORY
▸ Ways to rewrite:
▸ Rebase
▸ Cherry Pick
▸ Squash
▸ Amend
▸ Time Machine
▸ Perils of Rebasing
REBASE
▸ Apply each commit from current branch on top of the
target branch
▸ Example:
▸ git checkout feature-branch
▸ git rebase master
▸ Conflicts might arise in application of each commit
CHERRY PICK
▸ Example
▸ git cherry-pick eh1629ab1
▸ git cherry-pick feature-branch
▸ Take one commit and apply on top of some branch
SQUASH
▸ Example:
▸ git rebase 1na9n5m
▸ git rebase HEAD~3
▸ Then later choose which commits need to be squashed
▸ Remove unnecessary commits - Clean History
AMEND COMMIT
▸ Change commit snapshot
▸ Change contents
▸ Change commit message
▸ Usually the latest commit
▸ Example:
▸ Can add files before committing
▸ git commit —amend
▸ amends the latest commit
▸ git rebase HEAD~3
▸ then select to edit a commit - amends previous commit
TIME MACHINE!
▸ Go back in history
▸ Change history!
▸ Changing history has challenges
▸ DO NOT change shared history
▸ DO NOT change commits on branches that others have
based their work on
▸ Any of these operations changes the commit and all commits
based on that:
▸ rebase, cherry-pick, squash, amend
WORKFLOW
▸ Merge Requests
▸ CI status
▸ Code review
▸ Merge the Request
▸ Close issues via PR
▸ Deploy branches
▸ Specifics vary from project to project
GOOD PRACTICES
▸ Each commit should be a logical change entity
▸ Write good commit messages
▸ Imperative mood in the subject line
▸ Fix the flash message on password change
▸ Fixed password change
▸ Details in the message
▸ Use rebase instead of merge on your own PR
▸ Unless no-one else is working on the same branch
▸ Branch names with hiphens
REFERENCES
▸ ProGit Book: https://git-scm.com/book/en/v2
▸ Good commit messages: http://chris.beams.io/posts/git-
commit/

More Related Content

What's hot

Game DDOS Prevention
Game DDOS PreventionGame DDOS Prevention
Game DDOS PreventionWalter Liu
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of troubleJon Senchyna
 
Introduction to Version Control with GIT
Introduction to Version Control with GITIntroduction to Version Control with GIT
Introduction to Version Control with GITismet özöztürk
 
Scalability and Performance of CNS 3.6
Scalability and Performance of CNS 3.6Scalability and Performance of CNS 3.6
Scalability and Performance of CNS 3.6Gluster.org
 
Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Paradigma Digital
 
Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015
Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015
Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015DevOpsDays Tel Aviv
 
AGES Presentation on Web, Python, Django and GeoServer
AGES Presentation on Web, Python, Django and GeoServerAGES Presentation on Web, Python, Django and GeoServer
AGES Presentation on Web, Python, Django and GeoServerNg'eno Victor
 
How to store large binary files in git repositories
How to store large binary files in git repositoriesHow to store large binary files in git repositories
How to store large binary files in git repositoriesMatt Aunger
 
Node.js and Containers Go Together Like Peanut Butter and Jelly
Node.js and Containers Go Together Like Peanut Butter and JellyNode.js and Containers Go Together Like Peanut Butter and Jelly
Node.js and Containers Go Together Like Peanut Butter and JellyRoss Kukulinski
 
DSD-INT 2020 Deltares Open Archive NoSQL
DSD-INT 2020 Deltares Open Archive NoSQLDSD-INT 2020 Deltares Open Archive NoSQL
DSD-INT 2020 Deltares Open Archive NoSQLDeltares
 
Heketi Functionality into Glusterd2
Heketi Functionality into Glusterd2Heketi Functionality into Glusterd2
Heketi Functionality into Glusterd2Gluster.org
 
Git Introductive
Git IntroductiveGit Introductive
Git IntroductiveAdham Saad
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to gitEmanuele Olivetti
 
Gluster as Native Storage for Containers - past, present and future
Gluster as Native Storage for Containers - past, present and futureGluster as Native Storage for Containers - past, present and future
Gluster as Native Storage for Containers - past, present and futureGluster.org
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to KubernetesRoss Kukulinski
 
OpenShift.io on Gluster
OpenShift.io on GlusterOpenShift.io on Gluster
OpenShift.io on Glustermountpoint.io
 
How Openstack is Built
How Openstack is BuiltHow Openstack is Built
How Openstack is BuiltAnton Weiss
 

What's hot (20)

Game DDOS Prevention
Game DDOS PreventionGame DDOS Prevention
Game DDOS Prevention
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Introduction to Version Control with GIT
Introduction to Version Control with GITIntroduction to Version Control with GIT
Introduction to Version Control with GIT
 
Scalability and Performance of CNS 3.6
Scalability and Performance of CNS 3.6Scalability and Performance of CNS 3.6
Scalability and Performance of CNS 3.6
 
Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?
 
Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015
Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015
Terrible Ideas in Git - Corey Quinn, FutureAdvisor - DevOpsDays Tel Aviv 2015
 
AGES Presentation on Web, Python, Django and GeoServer
AGES Presentation on Web, Python, Django and GeoServerAGES Presentation on Web, Python, Django and GeoServer
AGES Presentation on Web, Python, Django and GeoServer
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
How to store large binary files in git repositories
How to store large binary files in git repositoriesHow to store large binary files in git repositories
How to store large binary files in git repositories
 
Node.js and Containers Go Together Like Peanut Butter and Jelly
Node.js and Containers Go Together Like Peanut Butter and JellyNode.js and Containers Go Together Like Peanut Butter and Jelly
Node.js and Containers Go Together Like Peanut Butter and Jelly
 
DSD-INT 2020 Deltares Open Archive NoSQL
DSD-INT 2020 Deltares Open Archive NoSQLDSD-INT 2020 Deltares Open Archive NoSQL
DSD-INT 2020 Deltares Open Archive NoSQL
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
Heketi Functionality into Glusterd2
Heketi Functionality into Glusterd2Heketi Functionality into Glusterd2
Heketi Functionality into Glusterd2
 
Git Introductive
Git IntroductiveGit Introductive
Git Introductive
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
From Java Monolith to k8s with CI/CD
From Java Monolith to k8s with CI/CD From Java Monolith to k8s with CI/CD
From Java Monolith to k8s with CI/CD
 
Gluster as Native Storage for Containers - past, present and future
Gluster as Native Storage for Containers - past, present and futureGluster as Native Storage for Containers - past, present and future
Gluster as Native Storage for Containers - past, present and future
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
OpenShift.io on Gluster
OpenShift.io on GlusterOpenShift.io on Gluster
OpenShift.io on Gluster
 
How Openstack is Built
How Openstack is BuiltHow Openstack is Built
How Openstack is Built
 

Viewers also liked

Open source-saturdays
Open source-saturdaysOpen source-saturdays
Open source-saturdaysTejas Bubane
 
Hidden features in ActiveRecord and the future
Hidden features in ActiveRecord and the futureHidden features in ActiveRecord and the future
Hidden features in ActiveRecord and the futureTejas Bubane
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessingksamyMCA
 
Introduction to Text Mining
Introduction to Text MiningIntroduction to Text Mining
Introduction to Text MiningMinha Hwang
 

Viewers also liked (9)

Open source-saturdays
Open source-saturdaysOpen source-saturdays
Open source-saturdays
 
Julia text mining_inmobi
Julia text mining_inmobiJulia text mining_inmobi
Julia text mining_inmobi
 
Hidden features in ActiveRecord and the future
Hidden features in ActiveRecord and the futureHidden features in ActiveRecord and the future
Hidden features in ActiveRecord and the future
 
Text Tokenization
Text TokenizationText Tokenization
Text Tokenization
 
Preprocessing
PreprocessingPreprocessing
Preprocessing
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
Introduction to Text Mining
Introduction to Text MiningIntroduction to Text Mining
Introduction to Text Mining
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 

Similar to Effective Git (20)

Source control management
Source control managementSource control management
Source control management
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Git
GitGit
Git
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and github
Git and githubGit and github
Git and github
 
Git
GitGit
Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
 
Git basic
Git basicGit basic
Git basic
 
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of GitGit Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git: a brief introduction
Git: a brief introductionGit: a brief introduction
Git: a brief introduction
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Basics of git
Basics of gitBasics of git
Basics of git
 
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Effective Git

  • 1. EFFECTIVE GIT - TEJAS BUBANE @tejasbubane
  • 2. CONTENTS ▸ Git Philosophy ▸ Log tree ▸ Commits and Branches ▸ Rewriting History ▸ Merge vs Rebase vs Squash vs Cherry-pick ▸ Workflow ▸ Good Practices
  • 3. THE GIT PHILOSOPHY ▸ Created by Linus Torvalds (after conflicts with Bitkeeper) ▸ For use in Linux kernel development ▸ Actually the Linux Philosophy ▸ Uses concepts from POSIX filesystem ▸ Stores snapshots not diffs ▸ All data stored in .git directory in delta compressed form ▸ Precise commands ▸ "Git" means an idiot (British Slang)
  • 4. DISTRIBUTED! ▸ Everyone has local copy of entire history ▸ Can work entirely independently of others ▸ Even without internet ▸ Remote - URL to push the code to ▸ clone brings the project, creates origin and master
  • 5. COMMIT OBJECTS ▸ One logical change in the codebase ▸ Message + Author (name, email) + Timestamp + Snapshots of all files + Parent(s) reference = checksum ▸ Everything is checksummed internally, each version of each file has checksum ▸ Checksum - SHA-1, Unique, 40 character hex (20 bytes)
  • 6. GIT HISTORY ▸ Commits have links with parent(s) ▸ Form a tree structure - Log tree - HISTORY ▸ Branches are nothing more than pointers to commit objects ▸ Pointers change - refer to different object ▸ Remote and local branches ▸ HEAD - symbolic pointer pointing to current branch
  • 7. MERGE ▸ git merge feature-branch ▸ Fast Forward ▸ Both commits are inline ▸ Just move the pointer to the next commit ▸ Non-fast-forward ▸ Commits not-inline ▸ Create a new snapshot and a merge commit ▸ Looks at nearest common parent to create new snapshot
  • 8. REWRITING HISTORY ▸ Ways to rewrite: ▸ Rebase ▸ Cherry Pick ▸ Squash ▸ Amend ▸ Time Machine ▸ Perils of Rebasing
  • 9. REBASE ▸ Apply each commit from current branch on top of the target branch ▸ Example: ▸ git checkout feature-branch ▸ git rebase master ▸ Conflicts might arise in application of each commit
  • 10. CHERRY PICK ▸ Example ▸ git cherry-pick eh1629ab1 ▸ git cherry-pick feature-branch ▸ Take one commit and apply on top of some branch
  • 11. SQUASH ▸ Example: ▸ git rebase 1na9n5m ▸ git rebase HEAD~3 ▸ Then later choose which commits need to be squashed ▸ Remove unnecessary commits - Clean History
  • 12. AMEND COMMIT ▸ Change commit snapshot ▸ Change contents ▸ Change commit message ▸ Usually the latest commit ▸ Example: ▸ Can add files before committing ▸ git commit —amend ▸ amends the latest commit ▸ git rebase HEAD~3 ▸ then select to edit a commit - amends previous commit
  • 13. TIME MACHINE! ▸ Go back in history ▸ Change history! ▸ Changing history has challenges ▸ DO NOT change shared history ▸ DO NOT change commits on branches that others have based their work on ▸ Any of these operations changes the commit and all commits based on that: ▸ rebase, cherry-pick, squash, amend
  • 14. WORKFLOW ▸ Merge Requests ▸ CI status ▸ Code review ▸ Merge the Request ▸ Close issues via PR ▸ Deploy branches ▸ Specifics vary from project to project
  • 15. GOOD PRACTICES ▸ Each commit should be a logical change entity ▸ Write good commit messages ▸ Imperative mood in the subject line ▸ Fix the flash message on password change ▸ Fixed password change ▸ Details in the message ▸ Use rebase instead of merge on your own PR ▸ Unless no-one else is working on the same branch ▸ Branch names with hiphens
  • 16. REFERENCES ▸ ProGit Book: https://git-scm.com/book/en/v2 ▸ Good commit messages: http://chris.beams.io/posts/git- commit/