Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8121317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:26:58+00:00 2026-06-06T05:26:58+00:00

Our git development workflow is that topic branches are continuously rebased on the latest

  • 0

Our git development workflow is that topic branches are continuously rebased on the latest master until they are merged.

However, a new developer has created topic branches in which he has done several merges of master into his topic branches to keep them up-to-date.

    A---B---C---D---E topic
   /       /   /
  F---G---H---I master

While merging this topic branch to master would be perfectly correct, it results in a very messy history. I want to convert these topic branches into a clean linear rebased history which can be merged cleanly into master with a single --no-ff merge commit i.e.:

                A'---B'---E' topic
               /
  F---G---H---I master

Ideally, there would be some git-fu that would allow me to do the rebase, taking the commits on the topic branch as-is, while automatically applying the merge conflict resolution information already available in the topic merge commits such as C and D.

I know I can simply apply the patch of “git diff master..topic” and then use rebase to work backwards and manually split apart the single patch into individual commits, but is there a simpler and more elegant approach?

I’ve tried straight git rebase and git rebase -p commands with no luck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:27:00+00:00Added an answer on June 6, 2026 at 5:27 am

    I found the following process seems to work reasonably well, though not perfectly. Some minor conflict resolutions may be required — see below.

    1. Ensure the topic branch is up-to-date with the latest master by doing a final merge from master, if not done already:

      git checkout topic
      git merge master
      
    2. Simplify the history of the topic branch by excluding merges:

      git log --no-merges
      
    3. From the above log, determine the branch point (the commit on master before the first topic branch commit, which should be commit F).

    4. Rebase the topic branch onto master, ignoring merges (which is the default, i.e. do not use the --preserve-merges / -p option), resolving any conflicts.

      git checkout master
      git rebase --onto HEAD F topic
      

      I found that during rebasing, often a conflict would result in which a file was in a conflicted “Both Modified” state, but it contained no conflict markers, so a simple git add and git rebase --continue was sufficient to resolve the conflict and continue. I believe git was using the previous resolution to resolve the conflicts.

      Also, in some more complex branches, multiple git rebase --onto HEAD ... commands will be required, or alternatively git cherry-pick can be used to pick out individual commits. Simply work through the log given in Step #2, rebasing ranges onto HEAD and/or potentially cherry-picking individual commits as necessary.

    5. The current HEAD should now represent the rebased topic branch. Verify that the result matches the original topic branch by checking that the diff results in no output:

      git diff topic..HEAD
      
    6. Name HEAD to the rebased topic branch name:

      git checkout -b rebased-topic
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At some point in our past branches of development in git were merged. However,
Our development process involves using git feature branches and code reviews done through github.
I pushed some changes to our central git repository, and then immediately realized that
I am using git-svn for our svn repository. However, the repo is huge, so
In our team we are using a development, staging and a master branch plus
Our team uses SVN to keep track of our day-to-day development. However, when it
Context We use several git repositories with the same workflow, involving two branches, and
We've been using Git for a node.js based web application. Our workflow is based
In our git-svn managed project, we have 3 upstream projects that are all kept
I use git to keep track of changes made by our development team and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.