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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:15:04+00:00 2026-05-24T14:15:04+00:00

I have fixed two bugs in a piece of code, and it modifies common

  • 0

I have fixed two bugs in a piece of code, and it modifies common files. For example, bug fix 1 modified file A, B, C, and bug fix 2 modified B, C, and D. I have all changes in one commit. For the purpose of code reviews, I need to split the changes into two commits (two branches actually).

What I am thinking is that from my current branch fix, I create two branches like git branch fix-1 fix and git branch fix-2 fix. Both branches have all changes. Now, in branch fix-1, I would like to keep the changes relevant to fix 1 only, that is, all changes in file A, and parts of changes in files B and C. Is it possible to do it in git? What command is relevant for this?

I know that in git add, I can do interactive add where I can select hunks of code for adding, not just at file level. Is there something similar I can do here?

  • 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-24T14:15:04+00:00Added an answer on May 24, 2026 at 2:15 pm

    If the commit was your last commit, here is a solution.

    1. Checkout the branch with the fix

      git checkout fix
      
    2. Reset back to before the fixes, but keep the changes in your working dir

      git reset HEAD^
      
    3. Create branch for fix-1

      git checkout -b fix-1
      
    4. Add/commit fix-1 fixes

      git add -p
      git commit
      
    5. Stash the remaining changes

      git stash
      
    6. Checkout/create branch for fix-2

      git checkout -b fix-1
      
    7. Pop off your stashed changes

      git stash pop
      
    8. Commit/add them

      git commit -a
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I have fixed all but two warnings now, so thank you all for
I have a fixed-length data file need to persistence into database. I use a
I have a class that is a container for two fixed length arrays as
I have a bunch of code below. However, I am hitting some bugs because
I have two fixed position arrows for next and previous blog posts on my
I can't make td Date to have fixed height. If there is less in
Header, footer and sidebars have fixed position. In the center a content area with
I have a fixed width DIV containing a table with many columns, and need
I have a problem with IE. I have a fixed div like this: #fixed
I want to remove digits from a float to have a fixed number of

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.