SlideShare a Scribd company logo
1 of 26
Download to read offline
Git Rebase vs Merge
a deep dive into the mysteries of revision control
Merge
Merge
a new commit on top of both branches that
should be merged - known as merge commit
Merge
You work on feature_branch
Merge
Before pushing you update your branch with master’s
changes - git pull origin master
Merge
git pull = git fetch + git merge
git fetch - copies origin master into origin/master
git merge - merges origin/master into master
Merge history graph
Merge - Pros & Cons
Pros:
● Simple to use and understand.
● Keeps information about the historical existence of branches.
● Existing commits on the source branch are unchanged and remain valid.
Cons:
● History can become intensively polluted by lots of merge commits.
● Visual charts of your repository can have non-informative branch lines.
Rebase
a different approach
Rebase
a way to cut of a set of commits from a branch
and apply those commits on another branch
Rebase
Let’s get back to our previous example:
Rebase
What does rebase do: It cuts off these commits
The commits don’t have any information about their parents
anymore.
Rebase
The system then applies them on top of the new branch.
We literally cut of these commits and then apply it on top of
the new branch.
Rebase
Why does merge even exists if we found such a nice way
to handle our history?
Our commit IDs changed!
Why?
Rebase
...because we have a new parent.
Git thinks of our commits as patches and applies them on
top of the new branch.
Therefore Git processes our commits as new commits.
And again, NEW COMMITS!
Rebase
git rebase [branch]
Rebase - Golden Rule
● Never rebase commits that you have pushed
to a public repository. Only rebase local
branches.
Why?
Rebase - Golden Rule
● When you rebase pushed branch, you’re
abandoning existing commits and creating
new ones that are similar but different.
So you will rewrite the history...
Rebase history graph
Rebase - Pros & Cons
Pros:
● Clean and flat history.
● Concise commits covering a logical change (can squash series of commits
into one)
● Reduction of merge commits
● Manipulating single commit is easy (e.g. reverting a commit)
Cons:
● More complex
● Rebasing can be dangerous! Can cause history rewrite if done incorrectly
The key of having a clean history
… is to have a “fast forward” effect
Fast Forward
Rebase - Best Practice
$ git checkout -b security_hole_fix
...fix...fix...fix
$ git commit
$ git rebase master
$ git checkout master
$ git merge security_hole_fix
then you get fast-forward effect
Who uses what?
Merge
➔ Atlassian (with GitHub pull requests for code reviews)
➔ Git
Rebase
➔ Guava
Rebase
If you are not sure you fully understand rebase
-
Don’t do it…
BUT
If you like it, try out !!!

More Related Content

What's hot

Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow IntroductionDavid Paluy
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requestsBartosz Kosarzycki
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with GitLuigi De Russis
 
Git Branching for Agile Teams
Git Branching for Agile Teams Git Branching for Agile Teams
Git Branching for Agile Teams Atlassian
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction TutorialThomas Rausch
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Noa Harel
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
Git workflows
Git workflowsGit workflows
Git workflowsXpand IT
 

What's hot (20)

Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git
GitGit
Git
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Git Branching for Agile Teams
Git Branching for Agile Teams Git Branching for Agile Teams
Git Branching for Agile Teams
 
Learning git
Learning gitLearning git
Learning git
 
git and github
git and githubgit and github
git and github
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Git
GitGit
Git
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 

Viewers also liked

Git rebase explained
Git rebase explainedGit rebase explained
Git rebase explainedMahesh Vaidya
 
Git for beginner
Git for beginnerGit for beginner
Git for beginnerTrung Huynh
 
Conflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their ImplicationsConflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their ImplicationsYoungSeok Yoon
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowMikhail Melnik
 
Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)Karel Minarik
 
Git Flow and JavaScript Coding Style
Git Flow and JavaScript Coding StyleGit Flow and JavaScript Coding Style
Git Flow and JavaScript Coding StyleBo-Yi Wu
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositoriesJulien Pivotto
 
Zero to Mongo in 60 Hours
Zero to Mongo in 60 HoursZero to Mongo in 60 Hours
Zero to Mongo in 60 HoursMongoSF
 

Viewers also liked (12)

Git rebase explained
Git rebase explainedGit rebase explained
Git rebase explained
 
Git for beginner
Git for beginnerGit for beginner
Git for beginner
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
 
Sendo um GIT master
Sendo um GIT masterSendo um GIT master
Sendo um GIT master
 
Conflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their ImplicationsConflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their Implications
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
 
Minicurso Git
Minicurso GitMinicurso Git
Minicurso Git
 
Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)
 
Git Flow and JavaScript Coding Style
Git Flow and JavaScript Coding StyleGit Flow and JavaScript Coding Style
Git Flow and JavaScript Coding Style
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
 
Zero to Mongo in 60 Hours
Zero to Mongo in 60 HoursZero to Mongo in 60 Hours
Zero to Mongo in 60 Hours
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 

Similar to Git Rebase vs Merge

Git rewriting git history
Git   rewriting git  historyGit   rewriting git  history
Git rewriting git historyLearningTech
 
Working with others using git and Github
Working with others using git and GithubWorking with others using git and Github
Working with others using git and GithubJacob Jenkins
 
Advanced Git - Functionality and Features
Advanced Git - Functionality and FeaturesAdvanced Git - Functionality and Features
Advanced Git - Functionality and FeaturesAll Things Open
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
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 slideRaghavendraVattikuti1
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced gitGerrit Wanderer
 
Git tutorial
Git tutorialGit tutorial
Git tutorialmobaires
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)Carlos Duarte do Nascimento
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-BryanLearningTech
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221Shinho Kang
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanJames Ford
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperJohn Stevenson
 

Similar to Git Rebase vs Merge (20)

Git tips
Git tipsGit tips
Git tips
 
Git rewriting git history
Git   rewriting git  historyGit   rewriting git  history
Git rewriting git history
 
Working with others using git and Github
Working with others using git and GithubWorking with others using git and Github
Working with others using git and Github
 
GIT Rebasing and Merging
GIT Rebasing and MergingGIT Rebasing and Merging
GIT Rebasing and Merging
 
Advanced Git - Functionality and Features
Advanced Git - Functionality and FeaturesAdvanced Git - Functionality and Features
Advanced Git - Functionality and Features
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
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
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Introduction to Git (part 2)
Introduction to Git (part 2)Introduction to Git (part 2)
Introduction to Git (part 2)
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)
 
MakingGitWorkForYou
MakingGitWorkForYouMakingGitWorkForYou
MakingGitWorkForYou
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221
 
Git Best Practices.pptx
Git Best Practices.pptxGit Best Practices.pptx
Git Best Practices.pptx
 
Git like a pro EDD18 - Full edition
Git like a pro EDD18 - Full editionGit like a pro EDD18 - Full edition
Git like a pro EDD18 - Full edition
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
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
 
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
 
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 pragmaticscarlostorres15106
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"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
 
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
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
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
 
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
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"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...
 
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
 

Git Rebase vs Merge

  • 1. Git Rebase vs Merge a deep dive into the mysteries of revision control
  • 3. Merge a new commit on top of both branches that should be merged - known as merge commit
  • 4. Merge You work on feature_branch
  • 5. Merge Before pushing you update your branch with master’s changes - git pull origin master
  • 6. Merge git pull = git fetch + git merge git fetch - copies origin master into origin/master git merge - merges origin/master into master
  • 8. Merge - Pros & Cons Pros: ● Simple to use and understand. ● Keeps information about the historical existence of branches. ● Existing commits on the source branch are unchanged and remain valid. Cons: ● History can become intensively polluted by lots of merge commits. ● Visual charts of your repository can have non-informative branch lines.
  • 10. Rebase a way to cut of a set of commits from a branch and apply those commits on another branch
  • 11. Rebase Let’s get back to our previous example:
  • 12. Rebase What does rebase do: It cuts off these commits The commits don’t have any information about their parents anymore.
  • 13. Rebase The system then applies them on top of the new branch. We literally cut of these commits and then apply it on top of the new branch.
  • 14. Rebase Why does merge even exists if we found such a nice way to handle our history? Our commit IDs changed! Why?
  • 15. Rebase ...because we have a new parent. Git thinks of our commits as patches and applies them on top of the new branch. Therefore Git processes our commits as new commits. And again, NEW COMMITS!
  • 17. Rebase - Golden Rule ● Never rebase commits that you have pushed to a public repository. Only rebase local branches. Why?
  • 18. Rebase - Golden Rule ● When you rebase pushed branch, you’re abandoning existing commits and creating new ones that are similar but different. So you will rewrite the history...
  • 20. Rebase - Pros & Cons Pros: ● Clean and flat history. ● Concise commits covering a logical change (can squash series of commits into one) ● Reduction of merge commits ● Manipulating single commit is easy (e.g. reverting a commit) Cons: ● More complex ● Rebasing can be dangerous! Can cause history rewrite if done incorrectly
  • 21. The key of having a clean history … is to have a “fast forward” effect
  • 23. Rebase - Best Practice $ git checkout -b security_hole_fix ...fix...fix...fix $ git commit $ git rebase master $ git checkout master $ git merge security_hole_fix then you get fast-forward effect
  • 24. Who uses what? Merge ➔ Atlassian (with GitHub pull requests for code reviews) ➔ Git Rebase ➔ Guava
  • 25. Rebase If you are not sure you fully understand rebase - Don’t do it… BUT
  • 26. If you like it, try out !!!