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 5978703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:33:16+00:00 2026-05-22T21:33:16+00:00

I have 2 branches, master and featureA. In the featureA branch I have written

  • 0

I have 2 branches, master and featureA. In the featureA branch I have written a bunch of new code in CoolFile.m . The feature isn’t done so this code is not yet ready to be merged into master.
CoolFile was really poorly written in the past so in the develop branch I commited a bunch of changes to it (mostly reordering methods, adding comments, and deleting whitespace).

Now I want rebase featureA off of master so that I can benefit from the cleaned up code. The problem is that since all the methods have moved around, the rebase is trying to put all the new code in the wrong places. What’s the best way to fix this? Should I have just waited until the feature was done to refactor?

  • 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-05-22T21:33:17+00:00Added an answer on May 22, 2026 at 9:33 pm

    You could merge the changes from the master branch into your featureA branch,

    A--B--F--G--H master
       \
        \-C--D--E featureA
    

    Lets assume you created featureA from commit B on master, and that C, D and E are commits made on featureA and F and G are the commits that reordered the methods etc. What you want to do now, is to merge F and G into the featureA branch.

    $ git checkout featureA
    $ git merge G (G is the sha1)
    

    Or, you could cherry pick the commits F and G into featureA. Remember that you will still get conflicts and that these are just alternatives to your rebase option.

    In the future I’d recommend that you do the refactoring either directly on featureA, or from another branch, branching off from featureA:

    A--B--F--G--H master
       \
        \-C--D--E featureA
             \
              \-I--J--K refactorFeatureA
    

    Then it’s a piece of cake to merge in the refactoring branch into featureA, since the merge would be trivial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several feature branches and a master branch. Feature2 is done. Normally I
I have two branches: master and dev I want to create a "feature branch"
A local branch:- 'feature/100' And Remote branches:- 'master' 'Version2' Accidently, I have merged my
A local branch:- 'feature/100' And Remote branches:- 'master' 'Version2' Accidently, I have merged my
I have three branches (let's call them master, testing, and feature). All three are
I have a 'master' branch and several topic branches. Assume that the master branch
I have two branches off of master, each one for a different feature, and
,Let's say I have a master Git branch and a feature branch off of
I have two branches, master and feature . I finished working on feature ,
I'm new to Git and a bit confused. I have a Master branch 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.