Skip to content
  • Home
  • Search
  • Tools
  • About
  • Terms of Service Agreement
  • Log In
  • Guest

Git: Rebase – When and Where Not To Do

Posted on January 19, 2021August 2, 2023 By Andre Dias
versioning

There are many good posts about the differences between pulling with and without rebase, merge and etc.
If you desire to refresh memory about this, try these:

git: the difference between git pull and git pull –rebase

Git Branching and Merge vs Rebase- 

This post intends to supply information on when and where not to do a rebase.
Through an example of our typical day life when things go wrong and the documentation let interrogation marks on your mind: and what does it happen then?


Scenario

Suppose that the master branch is very difficult to understand, having so many threads tangled among them that you start thinking about if “rebasing” wouldn’t help.
Please, for the sake of your own happiness and dignity, don’t.

Why?
The short answer is this:

First, you’ll change the original information and your team may not approve it.
So, ask them first.

Second, all operations involve risk and things may not happen as expected.
Murphy is elsewhere, unfortunately — or not, looking the other way around, you may concern that makes our life more exciting and challenging, after all, if everything always works well, life would lose that feeling of risk that turns life so exciting.

So, better to get prepared to handle “Murphy”! 🙂

ONE USE CASE AS AN EXAMPLE

Performing the master’s rebasing:

git checkout master
git pull –rebase

Usually, you may get a conflict to solve.
Basing on GitHub’s documentation, you perform the fix.

As supposed, any documentation must concern about the usual procedure supposing an optimist scenario and sometimes adding extra direction to some issues.
Issues are part of our IT daily life, always challenging us with unexpected ones.
Below, I transcribe parts of its documentation to make things easier (italic).

 

#Resolving merge conflicts after a Git rebase

When you perform a git rebase operation, you’re typically moving commits around. Because of this, you might get into a situation where a merge conflict is introduced. That means that two of your commits modified the same line in the same file, and Git doesn’t know which change to apply.

After you reorder and manipulate commits using git rebase, should a merge conflict occur, Git will tell you so with the following message printed to the terminal:

error: could not apply fa39187... something to add to patch A

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply fa39187f3c3dfd2ab5faa38ac01cf3de7ce2e841... Change fake file

Here, Git is telling you which commit is causing the conflict (fa39187). You’re given three choices:

  • You can run git rebase --abort to completely undo the rebase. Git will return you to your branch’s state as it was before git rebase was called.
  • You can run git rebase --skip to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option.
  • You can fix the conflict.

To fix the conflict, you can follow the standard procedures for resolving merge conflicts from the command line. When you’re finished, you’ll need to call git rebase --continue in order for Git to continue processing the rest of the rebase.

FIXING REBASE CONFLICT SUMMARY

To fix the conflict, you can follow the standard procedures for resolving merge conflicts from the command line. When you’re finished, you’ll need to call “git rebase --continue" in order for Git to continue processing the rest of the rebase.

1. To discover the conflicts, do:
git status

2. Edit the file that has the conflict and solve it.

<<<<<<< HEAD
The original code from the current state of the file before the rebase operation
=======
The new code to be merged from the rebase operation
>>>>>>> branch-a

FINISH THE REBASE OPERATION AFTER FIXING CONFLICTS

3. Add or stage your changes.
git add .

4. Commit your changes with a comment.
git commit -m “Resolved merge conflict by incorporating both suggestions.”

5. Finish rebase:
git rebase –continue

@FROM:
docs.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-using-the-command-line

WHEN GIT REFUSES TO CONTINUE

The rebase operation takes place:

 

What if, after resolving the merge conflict, the “git rebase –continue” still rejects and continues returning that message: “the merge must be done”!
You think: I’ve already solved the conflict, then performed “git add”, after performed commit, but it is still refusing.
What do I do?

 

 

If no other idea comes to mind, well, it is when the third option comes into place: the skip option:
git rebase –skip

The file’s content is preserved as it is but there is a side effect — the track of that merge thread will not meet the target thread as usual, getting something like this:

 

On the right, we have the log before rebasing.
On the left, the log after rebasing with a skip operation, where it is lost the merge that originally had for “c0f92f1”.

CONCLUSION: some information was lost in the master’s history.
Something that is not really desirable.

WHEN SHALL I USE REBASE, THEN…

I think it is useful to rebase your working branch, putting on top of it your current commits.
It gives us the chance to handle conflicts as if we had an update (pull) before starting to make our changes in the code.
This enables us to a better understanding of what our team has been changing and how it was done out of our interference.

The “–continue” operation fits very well this approach.

 

 

Andre Dias
Andre Dias

Brazilian system analyst graduated by UNESA (University Estácio de Sá – Rio de Janeiro). Geek by heart.

Post navigation

❮ Previous Post: AutoAjuda: O Sucesso é Cultivado
Next Post: Angular: Bootstrap Install Strategies ❯

Search

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
angular
bootstrap
browser
computer science
container
data persistence
database
devops
editors
hardware
health
hosting
info
internet
it
java
javascript
network
node.js
play
protocol
security
self-help
selfhelp
server
services
soft
software engeneering
sql
support
Systems
techs
Uncategorized
versioning
web
web design
windows
wordpress

Recent Posts

  • Angular From Scratch Tutorial – Step 9: Modal
  • Angular From Scratch Tutorial – Step 8: Miscellany
  • Angular From Scratch Tutorial – Index
  • angular: Reading JSON files
  • NODE.JS: SEQUELIZE: MVC Project – 4TH STEP

Categories

  • angular (19)
  • bootstrap (6)
  • browser (4)
  • computer science (4)
  • container (1)
  • data persistence (2)
  • database (11)
  • devops (1)
  • editors (1)
  • hardware (4)
  • health (2)
  • hosting (1)
  • info (1)
  • internet (2)
  • it (1)
  • java (13)
  • javascript (32)
  • network (6)
  • node.js (1)
  • play (1)
  • protocol (1)
  • security (4)
  • self-help (1)
  • selfhelp (1)
  • server (2)
  • services (1)
  • soft (1)
  • software engeneering (1)
  • sql (1)
  • support (2)
  • Systems (1)
  • techs (3)
  • Uncategorized (2)
  • versioning (6)
  • web (1)
  • web design (5)
  • windows (3)
  • wordpress (4)

Copyright © 2025 .

Theme: Oceanly by ScriptsTown

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT