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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:12:03+00:00 2026-05-25T17:12:03+00:00

git version 1.7.5.4 Ubuntu 11.10 Is it possible to merge some selected pieces of

  • 0

git version 1.7.5.4
Ubuntu 11.10

Is it possible to merge some selected pieces of source code across a few files?

I have been working on 2 different branches i.e. branch1 and branch2.

Currently I am on branch2, and there are some changes from branch1 that I want to add to branch2.

All the selected pieces I want are on a single commit on branch1.

I could just switch to branch1 copy the changes, then switch back to branch2 and paste them in. However, I would rather learn how git could do this for me.

Also, I am worried that if I use git I could merge some changes from branch1 that I do not want in branch2. So that is why I want to do it by selecting the pieces.

Many thanks for any suggestions,

  • 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-25T17:12:04+00:00Added an answer on May 25, 2026 at 5:12 pm

    That’s not really how git works. When you merge commits, you either merge the entire commit or you don’t merge any of it – otherwise, the integrity of the history graph would be compromised.

    What you could do is:

    1. git checkout -b temp_branch branch2
    2. git checkout branch1 /path/to/file/with_changes
    3. Repeat step #2 for each file involved.
    4. git reset HEAD
    5. git add -p and only stage the portions of the file changes that you want.
    6. git commit
    7. git checkout -f branch2
    8. git merge temp_branch

    This would merge in a new, different commit from those on branch1 that had the partial changes – but note that if you later went to merge branch1 into branch2, you’d have to manually resolve the conflicts, because creating the new partial-changes commit makes a separate, distinct branch of history.

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

Sidebar

Related Questions

git version 1.7.4.1 I am using git on Ubuntu. I have copied some files
I'm using Git for version control and unlike SVN I have not come across
I have been using Git for my version control for a while now, but
I am using ubuntu 11.10 machine. I have installed git of version 1.7.7.1. I
I have Git (version 1.7.2.5) bash compeletion working on my Debian squeeze (6.0). Git
I know how to get the latest source from GIT which is version 7.1.2
git version 1.7.7 I have dropbox git repository. From my works computer karl-sun I
I am using git version 1.7.2.3 and I have the following situation: Clone git
Since which git version is it possible to to do git clone --mirror ?
git version 1.7.4.1 Ubuntu Currently I am working on a project at my company.

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.