SlideShare a Scribd company logo
Git Tips
by Arthur Shvetsov
CoreValue/MalkosUA
Agenda
● Git common principles and design goals
● Merging vs. Rebasing
● How to rewrite history?
● A successful Git branching model
What is Git?
● Git is a distributed revision control and source code
management (SCM) system with an emphasis on
speed, data integrity, and support for distributed, non-
linear workflows.
● Git was initially designed and developed by Linus
Torvalds for Linux kernel development in 2005, and has
since become the most widely adopted version control
system for software development.
Git design goals
● Speed
● Simple design
● Strong support for thousands of parallel branches
● Fully distributed
o full local repository
o offline commits
o full size repository
● Able to handle large projects like Linux kernel effectively
● Ensure integrity
Git drawbacks
● Big committed files will be in every clone of
repository
● No partial checkout
● No lock
● No support of empty directories
Git philosophy
● Commit early, commit often
● One commit represents one idea or one
change
o Make it easy to read patches
o Easy to revert unwanted changes later
● Your working directory, index and local
repository are your scratch pads
Git architecture
Nearly Every Operation Is Local
Snapshots, Not Differences
The major difference between Git and any
other VCS (Subversion and friends included) is
the way Git thinks about its data.
Tracking changes (most VCS)
Storing data as changes to a base version of each file
Tracking changes (the Git way)
Storing data as snapshots of the project over time
Git Generally Only Adds Data
File status lifecycle
The Staging Area
The staging area is a buffer between the
working directory and the project repository.
What happens when you create a
commit ?
Git tips
What happens when you create a
new branch?
$ git branch testing
How does Git know what branch
you’re currently on?
What happens when you switch a
branch?
$ git checkout testing
Merging vs. Rebasing
Merging vs. Rebasing
git rebase and git merge - both of these
commands are designed to solve the same
problem - integrate changes from one branch
into another branch — they just do it in very
different ways.
A forked commit history
To incorporate the new commits into your feature branch,
you have two options: merging or rebasing.
Merging master into feature branch
$ git checkout feature
$ git merge master
Pros
● Simple to use and understand
● Merging is a non-destructive operation
● The existing branches are not changed in any way
Cons
● The feature branch will have an extraneous merge
commit every time you need to incorporate changes
● Visual charts of repository can have non-informative
branch lines
Git merge pros and cons
The Rebase Option
$ git checkout feature
$ git rebase master
Pros
● Much cleaned project history
● Eliminates the unnecessary merge commits required by git merge
● A perfectly linear project history
Cons
● Re-writing project history can be potentially catastrophic for your
collaboration workflow
● Rebasing loses the context provided by a merge commit - you can’t
see when upstream changes were incorporated into the feature
Git rebase pros and cons
Git rebase golden rule
Never use git rebase on public branches. Only rebase
local branches
When you rebase pushed branch, you’re
abandoning existing commits and creating
new ones that are similar but different
Interactive Rebase
$ git checkout feature
$ git rebase -i master
Pros
● Eliminating insignificant commits like this makes
your feature’s history much easier to understand.
This is something that git merge simply cannot do
Interactive rebase pros, no cons :)
Force Pushing
$ git push -f origin feature
Integrating an Approved Feature
Integrating an Approved Feature
Integrating an Approved Feature.
“Fast forward” effect
Rebasing a temporary branch
git checkout feature
git checkout -b temporary-branch
git rebase -i master
git checkout master
git merge temporary-branch
Git pull --rebase
By default, the git pull command performs a
merge, but you can force it to integrate the
remote branch with a rebase by passing it the --
rebase option.
$ git config branch.autosetuprebase always
How to rewrite history?
Git revert
Reverting undoes a commit by creating a new
commit. This is a safe way to undo changes, as
it has no chance of re-writing the commit
history.
$ git checkout hotfix
$ git revert HEAD~2
Git reset
Git reset as the dangerous method. When you
undo with git reset, there is no way to retrieve
the original copy—it is a permanent undo.
$ git checkout hotfix
$ git reset HEAD~2
Reverting vs. Resetting
git checkout
● checking out branches
● checking out commits - makes the entire
working directory match that commit
● checking out files - lets you see an old
version of that particular file, leaving the rest
of your working directory untouched
“Detached HEAD” state
$ git checkout HEAD~2
Multiple ways how to rewrite
history?
● $ git reset
● $ git rebase
Git cherry-pick
Applies the changes introduced by some
existing commits to specific branch
$ git checkout feature-branch
$ git cherry-pick <commit hash>
Stashing
Records the current state of the working
directory and the index, and cleans up the
working directory
$ git stash
Submodules
Submodule allows you to keep another Git
repository in a subdirectory of your repository
$ git submodule
A successful Git branching model
Decentralized but centralized
The main branches
● master
o contains production ready code
● develop
o an integration branch
o contains the latest changes
o used for nightly builds
o getting a production release
when merging with master
Supporting branches
● Feature branches
● Release branches
● Hotfix branches
Feature branches (topic branches)
● May branch off from:
o develop
● May merge back into:
o develop
● Branching name convention:
o anything except master, develop,
release-* or hotfix-*
Creating a feature branch
$ git checkout -b myfeature develop
Switched to a new branch “myfeature”
Incorporating a finished feature on develop
$ git checkout develop
Switched to branch 'develop'
$ git merge myfeature
Updating ea1b82a..05e9557 (Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).
$ git push origin develop
Release branches
● May branch off from:
o develop
● Must merge back into:
o develop and master
● Branch naming convention:
o release-*
● Used for preparation of a new production release
● Allow minor bug-fixes
Creating a release branch
$ git checkout -b release-1.2 develop
Switched to a new branch "release-1.2"
Finishing a release branch
$ git checkout master
Switched to branch 'master'
$ git merge release-1.2
Merge made by recursive. (Summary of changes)
$ git tag -a 1.2
$ git checkout develop
Switched to branch 'develop'
$ git merge release-1.2
Merge made by recursive. (Summary of changes)
$ git branch -d release-1.2
Deleted branch release-1.2 (was ff452fe).
Hotfix branches
● May branch off from:
o master
● Must merge back into:
o develop and master
● Branch naming convention:
o hotfix-*
Creating a hotfix branch
$ git checkout -b hotfix-1.2.1 master
Switched to a new branch "hotfix-1.2.1"
$ git commit -m "Fixed severe production problem"
[hotfix-1.2.1 abbe5d6] Fixed severe production problem 5
files changed, 32 insertions(+), 17 deletions(-)
Finishing a hotfix branch
$ git checkout master
Switched to branch 'master'
$ git merge hotfix-1.2.1
Merge made by recursive. (Summary of changes)
$ git tag -a 1.2.1
$ git checkout develop
Switched to branch 'develop'
$ git merge hotfix-1.2.1
Merge made by recursive. (Summary of changes)
$ git branch -d hotfix-1.2.1
Deleted branch hotfix-1.2.1 (was abbe5d6).
Links and Literature
● Pro Git
● A successful Git branching model
● https://www.atlassian.com/git/tutorials/
● https://help.github.com/
Thank You!
Ad

More Related Content

What's hot (20)

A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
Hüseyin Ergin
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
Martin Jinoch
 
Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control system
Jeroen Rosenberg
 
Real-World Git
Real-World GitReal-World Git
Real-World Git
Rick Warren
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primer
saadulde
 
Training: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, MavenTraining: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, Maven
Artur Ventura
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and Tags
Mikhail Melnik
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
DSCVSSUT
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Shilu Shrestha
 
Take the next step with git
Take the next step with gitTake the next step with git
Take the next step with git
Karin Taliga
 
git Technologies
git Technologiesgit Technologies
git Technologies
Hirantha Pradeep
 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...
SlideTeam
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
Dana White
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
Md. Main Uddin Rony
 
Advanced Git: Functionality and Features
Advanced Git: Functionality and FeaturesAdvanced Git: Functionality and Features
Advanced Git: Functionality and Features
Brent Laster
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Git
GitGit
Git
Majid Hajiloo
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for Everyone
GLC Networks
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
Hüseyin Ergin
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
Martin Jinoch
 
Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control system
Jeroen Rosenberg
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primer
saadulde
 
Training: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, MavenTraining: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, Maven
Artur Ventura
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and Tags
Mikhail Melnik
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
DSCVSSUT
 
Take the next step with git
Take the next step with gitTake the next step with git
Take the next step with git
Karin Taliga
 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...
SlideTeam
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
Dana White
 
Advanced Git: Functionality and Features
Advanced Git: Functionality and FeaturesAdvanced Git: Functionality and Features
Advanced Git: Functionality and Features
Brent Laster
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for Everyone
GLC Networks
 

Similar to Git tips (20)

Git tutorial
Git tutorialGit tutorial
Git tutorial
mobaires
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
Bartosz Kosarzycki
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
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
Katie Sylor-Miller
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
Tilton2
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
RaghavendraVattikuti1
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
Hasnaeen Rahman
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
Sergiu-Ioan Ungur
 
Introduction into Git
Introduction into GitIntroduction into Git
Introduction into Git
Serhii Kartashov
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
Pablo Quiroga
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
Pablo Quiroga
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
Priyanka Nag
 
Git slides
Git slidesGit slides
Git slides
Nanyak S
 
Lets git to it
Lets git to itLets git to it
Lets git to it
Yoram Michaeli
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
mobaires
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
Bartosz Kosarzycki
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
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
Katie Sylor-Miller
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
Tilton2
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
RaghavendraVattikuti1
 
Git slides
Git slidesGit slides
Git slides
Nanyak S
 
Ad

Recently uploaded (20)

TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Shift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software DevelopmentShift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software Development
SathyaShankar6
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Mastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core PillarsMastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core Pillars
Marcel David
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Xforce Keygen 64-bit AutoCAD 2025 Crack
Xforce Keygen 64-bit AutoCAD 2025  CrackXforce Keygen 64-bit AutoCAD 2025  Crack
Xforce Keygen 64-bit AutoCAD 2025 Crack
usmanhidray
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Shift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software DevelopmentShift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software Development
SathyaShankar6
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Mastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core PillarsMastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core Pillars
Marcel David
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Xforce Keygen 64-bit AutoCAD 2025 Crack
Xforce Keygen 64-bit AutoCAD 2025  CrackXforce Keygen 64-bit AutoCAD 2025  Crack
Xforce Keygen 64-bit AutoCAD 2025 Crack
usmanhidray
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Ad

Git tips

  • 1. Git Tips by Arthur Shvetsov CoreValue/MalkosUA
  • 2. Agenda ● Git common principles and design goals ● Merging vs. Rebasing ● How to rewrite history? ● A successful Git branching model
  • 3. What is Git? ● Git is a distributed revision control and source code management (SCM) system with an emphasis on speed, data integrity, and support for distributed, non- linear workflows. ● Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005, and has since become the most widely adopted version control system for software development.
  • 4. Git design goals ● Speed ● Simple design ● Strong support for thousands of parallel branches ● Fully distributed o full local repository o offline commits o full size repository ● Able to handle large projects like Linux kernel effectively ● Ensure integrity
  • 5. Git drawbacks ● Big committed files will be in every clone of repository ● No partial checkout ● No lock ● No support of empty directories
  • 6. Git philosophy ● Commit early, commit often ● One commit represents one idea or one change o Make it easy to read patches o Easy to revert unwanted changes later ● Your working directory, index and local repository are your scratch pads
  • 9. Snapshots, Not Differences The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data.
  • 10. Tracking changes (most VCS) Storing data as changes to a base version of each file
  • 11. Tracking changes (the Git way) Storing data as snapshots of the project over time
  • 12. Git Generally Only Adds Data
  • 14. The Staging Area The staging area is a buffer between the working directory and the project repository.
  • 15. What happens when you create a commit ?
  • 17. What happens when you create a new branch? $ git branch testing
  • 18. How does Git know what branch you’re currently on?
  • 19. What happens when you switch a branch? $ git checkout testing
  • 21. Merging vs. Rebasing git rebase and git merge - both of these commands are designed to solve the same problem - integrate changes from one branch into another branch — they just do it in very different ways.
  • 22. A forked commit history To incorporate the new commits into your feature branch, you have two options: merging or rebasing.
  • 23. Merging master into feature branch $ git checkout feature $ git merge master
  • 24. Pros ● Simple to use and understand ● Merging is a non-destructive operation ● The existing branches are not changed in any way Cons ● The feature branch will have an extraneous merge commit every time you need to incorporate changes ● Visual charts of repository can have non-informative branch lines Git merge pros and cons
  • 25. The Rebase Option $ git checkout feature $ git rebase master
  • 26. Pros ● Much cleaned project history ● Eliminates the unnecessary merge commits required by git merge ● A perfectly linear project history Cons ● Re-writing project history can be potentially catastrophic for your collaboration workflow ● Rebasing loses the context provided by a merge commit - you can’t see when upstream changes were incorporated into the feature Git rebase pros and cons
  • 27. Git rebase golden rule Never use git rebase on public branches. Only rebase local branches
  • 28. When you rebase pushed branch, you’re abandoning existing commits and creating new ones that are similar but different
  • 29. Interactive Rebase $ git checkout feature $ git rebase -i master
  • 30. Pros ● Eliminating insignificant commits like this makes your feature’s history much easier to understand. This is something that git merge simply cannot do Interactive rebase pros, no cons :)
  • 31. Force Pushing $ git push -f origin feature
  • 34. Integrating an Approved Feature. “Fast forward” effect
  • 35. Rebasing a temporary branch git checkout feature git checkout -b temporary-branch git rebase -i master git checkout master git merge temporary-branch
  • 36. Git pull --rebase By default, the git pull command performs a merge, but you can force it to integrate the remote branch with a rebase by passing it the -- rebase option. $ git config branch.autosetuprebase always
  • 37. How to rewrite history?
  • 38. Git revert Reverting undoes a commit by creating a new commit. This is a safe way to undo changes, as it has no chance of re-writing the commit history.
  • 39. $ git checkout hotfix $ git revert HEAD~2
  • 40. Git reset Git reset as the dangerous method. When you undo with git reset, there is no way to retrieve the original copy—it is a permanent undo.
  • 41. $ git checkout hotfix $ git reset HEAD~2
  • 43. git checkout ● checking out branches ● checking out commits - makes the entire working directory match that commit ● checking out files - lets you see an old version of that particular file, leaving the rest of your working directory untouched
  • 44. “Detached HEAD” state $ git checkout HEAD~2
  • 45. Multiple ways how to rewrite history? ● $ git reset ● $ git rebase
  • 46. Git cherry-pick Applies the changes introduced by some existing commits to specific branch $ git checkout feature-branch $ git cherry-pick <commit hash>
  • 47. Stashing Records the current state of the working directory and the index, and cleans up the working directory $ git stash
  • 48. Submodules Submodule allows you to keep another Git repository in a subdirectory of your repository $ git submodule
  • 49. A successful Git branching model
  • 51. The main branches ● master o contains production ready code ● develop o an integration branch o contains the latest changes o used for nightly builds o getting a production release when merging with master
  • 52. Supporting branches ● Feature branches ● Release branches ● Hotfix branches
  • 53. Feature branches (topic branches) ● May branch off from: o develop ● May merge back into: o develop ● Branching name convention: o anything except master, develop, release-* or hotfix-*
  • 54. Creating a feature branch $ git checkout -b myfeature develop Switched to a new branch “myfeature” Incorporating a finished feature on develop $ git checkout develop Switched to branch 'develop' $ git merge myfeature Updating ea1b82a..05e9557 (Summary of changes) $ git branch -d myfeature Deleted branch myfeature (was 05e9557). $ git push origin develop
  • 55. Release branches ● May branch off from: o develop ● Must merge back into: o develop and master ● Branch naming convention: o release-* ● Used for preparation of a new production release ● Allow minor bug-fixes
  • 56. Creating a release branch $ git checkout -b release-1.2 develop Switched to a new branch "release-1.2"
  • 57. Finishing a release branch $ git checkout master Switched to branch 'master' $ git merge release-1.2 Merge made by recursive. (Summary of changes) $ git tag -a 1.2 $ git checkout develop Switched to branch 'develop' $ git merge release-1.2 Merge made by recursive. (Summary of changes) $ git branch -d release-1.2 Deleted branch release-1.2 (was ff452fe).
  • 58. Hotfix branches ● May branch off from: o master ● Must merge back into: o develop and master ● Branch naming convention: o hotfix-*
  • 59. Creating a hotfix branch $ git checkout -b hotfix-1.2.1 master Switched to a new branch "hotfix-1.2.1" $ git commit -m "Fixed severe production problem" [hotfix-1.2.1 abbe5d6] Fixed severe production problem 5 files changed, 32 insertions(+), 17 deletions(-)
  • 60. Finishing a hotfix branch $ git checkout master Switched to branch 'master' $ git merge hotfix-1.2.1 Merge made by recursive. (Summary of changes) $ git tag -a 1.2.1 $ git checkout develop Switched to branch 'develop' $ git merge hotfix-1.2.1 Merge made by recursive. (Summary of changes) $ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6).
  • 61. Links and Literature ● Pro Git ● A successful Git branching model ● https://www.atlassian.com/git/tutorials/ ● https://help.github.com/