SlideShare a Scribd company logo
Interactive Rebase
In this exercise you learn how you can rewrite the local history before you share it with
others. After you have committed locally you can still change all commits in your local
feature branch. You will use the interactive rebase feature which helps you combining
different actions in one operation.
Preparation
Follow exercise “Merging, Rebasing and Conflict Resolution”. After the rebase you end up
with a branch which is two commits ahead of the remote branch origin/master.
Add two additional commits
● In the feature branch, add a commit with a change you do not need and with another
commit which should in fact be part of the commit “Add multiply operation”
● Now you realize that you also want to edit the commit message of the commit “Add
divide operation”
Interactive Rebase
Interactive Rebase is a very powerful operation which allows to rewrite the history of a
branch. You can select a set of commits and specify for each one how it should be handled.
You can edit the commit message, edit the commit, skip the commit, change the order of
commits or squash commits together. We will try out some of the options in this exercise.
● Click “Rebase interactive” on the parent of the first commit you want to change in
order to start interactive rebase:
● Now open the “Git Interactive Rebase” View
The commits are presented in the order they will be processed by interactive rebase.
Change the action for each of the commits like shown here:
● Click on the “Start” button
The list of actions is processed from top to bottom.
● The first commit has the action REWORD. EGit opens a dialog where you can edit
the commit message. Press OK. The commit is replaced by a new one which has the
new commit message.
● The next commit is just picked. That means, that EGit cherry-picks this commit as
a successor of the first reworded commit which contains the same changes as the
picked commit.
● The next commit is skipped (removed on the branch rewritten by interactive rebase).
● The list of actions is updated during the Interactive Rebase:
● The last commit should be squashed with its predecessor commit. That means that a
new commit is created which replaces the predecessor and combines the changes of
both old commits. You can edit the commit message of the new commit in a dialog.
Note that the action FIXUP would also have combined the two commits but would
have silently taken the commit message of the first commit.
● As a result the history should look like this:
Note that the old “Add divide operation” commit is still in the history because the
branch “addDivideOperation” points to it.
Note: do not rewrite commits which have already been published (reached a branch on
the server) since other developers may have already based new changes on them. Use
interactive rebase only on local changes or on changes which have been pushed for review
(e.g. if you are using Gerrit for code review) but have not yet been accepted and merged to
a branch (by “submit” in Gerrit).
Copyright © 2014 by C. Halstrick, E. Kempin, S. Lay, S. Zivkov, M. Sohn

More Related Content

PDF
Difference between promise-chain and promise.all() in Javascript
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
PDF
Transition to More Powerful Jira Workflows
PPTX
Presentatie sjabloon skirt generators v2
PPTX
Roebuck
PDF
Git: basic to advanced
PDF
Change history with Git
PPTX
Git rewriting git history
Difference between promise-chain and promise.all() in Javascript
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Transition to More Powerful Jira Workflows
Presentatie sjabloon skirt generators v2
Roebuck
Git: basic to advanced
Change history with Git
Git rewriting git history

Similar to Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase (20)

PDF
Git Tricks — git utilities that make life git easier
DOCX
GIT Rebasing and Merging
PPTX
Use Git like a pro - condensed
PPTX
Git workshop
PDF
Git: Overview, Pitfalls, Best Practices
PDF
Keep you GIT history clean
PDF
Advanced Git Tutorial
PPTX
MakingGitWorkForYou
PDF
Git Tutorial EclipseCon France 2014 - Git Exercise 03 - work on branches in p...
PPTX
Git like a pro EDD18 - Full edition
PDF
Keep your GIT history clean
PPTX
Git for beginner
PPTX
Git For Beginer
PDF
git session --interactive
PPTX
Gitting out of trouble
PDF
Don't fear the rebase
PPTX
Git tips
PDF
Advanced Git - Functionality and Features
PDF
Effective Git
PDF
Git Rebase vs Merge
Git Tricks — git utilities that make life git easier
GIT Rebasing and Merging
Use Git like a pro - condensed
Git workshop
Git: Overview, Pitfalls, Best Practices
Keep you GIT history clean
Advanced Git Tutorial
MakingGitWorkForYou
Git Tutorial EclipseCon France 2014 - Git Exercise 03 - work on branches in p...
Git like a pro EDD18 - Full edition
Keep your GIT history clean
Git for beginner
Git For Beginer
git session --interactive
Gitting out of trouble
Don't fear the rebase
Git tips
Advanced Git - Functionality and Features
Effective Git
Git Rebase vs Merge
Ad

More from msohn (20)

PPTX
Project Gardener - EclipseCon Europe - 2018-10-23
PDF
News from Git in Eclipse - EclipseCon EU - 2016-10-26
PDF
Git journey from mars to neon EclipseCon North America - 2016-03-08
PDF
Versioning large binary files with JGit, EGit and Gerrit
PDF
News from Git in Eclipse - EclipseCon 2015 Europe
PPTX
Git missiontomars 2015-03-10
PPTX
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 7 - new changescreen
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 5 - improve a change
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 4 - review change
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 3 - push change to gerrit
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
PDF
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
PDF
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
PDF
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
PDF
Git Tutorial EclipseCon France 2014 - Git Exercise 04 - merging rebasing and ...
PDF
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
PDF
Git Tutorial EclipseCon France 2014 - Git Exercise 02 - develop a feature
Project Gardener - EclipseCon Europe - 2018-10-23
News from Git in Eclipse - EclipseCon EU - 2016-10-26
Git journey from mars to neon EclipseCon North America - 2016-03-08
Versioning large binary files with JGit, EGit and Gerrit
News from Git in Eclipse - EclipseCon 2015 Europe
Git missiontomars 2015-03-10
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 7 - new changescreen
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 5 - improve a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 4 - review change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 3 - push change to gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 04 - merging rebasing and ...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 02 - develop a feature
Ad

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PDF
medical staffing services at VALiNTRY
PDF
Digital Strategies for Manufacturing Companies
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Introduction to Artificial Intelligence
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
System and Network Administraation Chapter 3
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
history of c programming in notes for students .pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Nekopoi APK 2025 free lastest update
medical staffing services at VALiNTRY
Digital Strategies for Manufacturing Companies
Reimagine Home Health with the Power of Agentic AI​
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Design an Analysis of Algorithms II-SECS-1021-03
Introduction to Artificial Intelligence
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
L1 - Introduction to python Backend.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Odoo POS Development Services by CandidRoot Solutions
How to Migrate SBCGlobal Email to Yahoo Easily
PTS Company Brochure 2025 (1).pdf.......
Internet Downloader Manager (IDM) Crack 6.42 Build 41
System and Network Administraation Chapter 3
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
history of c programming in notes for students .pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)

Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase

  • 1. Interactive Rebase In this exercise you learn how you can rewrite the local history before you share it with others. After you have committed locally you can still change all commits in your local feature branch. You will use the interactive rebase feature which helps you combining different actions in one operation. Preparation Follow exercise “Merging, Rebasing and Conflict Resolution”. After the rebase you end up with a branch which is two commits ahead of the remote branch origin/master. Add two additional commits ● In the feature branch, add a commit with a change you do not need and with another commit which should in fact be part of the commit “Add multiply operation” ● Now you realize that you also want to edit the commit message of the commit “Add divide operation” Interactive Rebase Interactive Rebase is a very powerful operation which allows to rewrite the history of a branch. You can select a set of commits and specify for each one how it should be handled. You can edit the commit message, edit the commit, skip the commit, change the order of commits or squash commits together. We will try out some of the options in this exercise.
  • 2. ● Click “Rebase interactive” on the parent of the first commit you want to change in order to start interactive rebase: ● Now open the “Git Interactive Rebase” View The commits are presented in the order they will be processed by interactive rebase. Change the action for each of the commits like shown here: ● Click on the “Start” button The list of actions is processed from top to bottom. ● The first commit has the action REWORD. EGit opens a dialog where you can edit the commit message. Press OK. The commit is replaced by a new one which has the new commit message.
  • 3. ● The next commit is just picked. That means, that EGit cherry-picks this commit as a successor of the first reworded commit which contains the same changes as the picked commit. ● The next commit is skipped (removed on the branch rewritten by interactive rebase). ● The list of actions is updated during the Interactive Rebase: ● The last commit should be squashed with its predecessor commit. That means that a new commit is created which replaces the predecessor and combines the changes of both old commits. You can edit the commit message of the new commit in a dialog. Note that the action FIXUP would also have combined the two commits but would have silently taken the commit message of the first commit.
  • 4. ● As a result the history should look like this: Note that the old “Add divide operation” commit is still in the history because the branch “addDivideOperation” points to it. Note: do not rewrite commits which have already been published (reached a branch on the server) since other developers may have already based new changes on them. Use interactive rebase only on local changes or on changes which have been pushed for review (e.g. if you are using Gerrit for code review) but have not yet been accepted and merged to a branch (by “submit” in Gerrit). Copyright © 2014 by C. Halstrick, E. Kempin, S. Lay, S. Zivkov, M. Sohn