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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:11:58+00:00 2026-05-12T22:11:58+00:00

I understand how to merge branches together in git, and I love how easy

  • 0

I understand how to merge branches together in git, and I love how easy it makes it.

I have a branch that looks like this:

project/
|--subproj1/
|  |---(files)
|
|--subproj2/
   |---(files)

A colleague has a branch that’s made significant changes to both subprojects. More specifically, he’s altered them both to depend on a common bit of code in a new subproj3. However, for various reasons, we’re not pushing his branch anytime in the forseeable future.

My branch diverges from master only in subproj1, where I’m making subproject-specific enhancements. My subproject is less important than some of the others, and thus has less constraints on what types of changes we can push on it. I’d like to merge in my colleague’s subproj1 changes (and his new subproj3 which those changes depend on) but leave my existing subproj2 alone. Sometime in the future, when he merges his project in entirety to master, I’d like his subproj2 changes to merge in normally.

How do I do this with git?

  • 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-12T22:11:58+00:00Added an answer on May 12, 2026 at 10:11 pm

    Each commit is a logical unit of work. Unfortunately, that means you cannot separate the edits you colleague has made to subproj1 and subproj2 if he made them on the same branch.

    However, to do what you are asking, you would use git filter-branch. You can use this to create a new branch which is defined by replaying all of your colleague’s commits but only adding changes to subproj1 to each commit.

    The commands are something along the lines of:

    git fetch colleague-repo ...
    git filter-branch --subdirectory-filter subproj1 -- A..B
    

    (where A..B is the range of commits you fetch from his repository)

    By doing this you are creating a unique branch with work that is totally separate from your colleague’s work. If you merge this new branch and your colleague’s branch into master, the history of changes to subproj1 will permanently be split between the two branches.

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

Sidebar

Related Questions

I have created a branch like this svn copy svn+ssh://foo.bar/svn/myproject/trunk svn+ssh://foo.bar/svn/myproject/branches/feature-x I then proceeded
I am tryin gto understand branches in git.I have worked with SVN so trying
I understand this may sound like an odd question.. I have a repo on
Let's say I have a mercurial project and I do this: hg branch whatever
I have gotten so far to understand that merge() is an option to copy
We have the trunk of out project at http://server/repositiory/project/trunk and a branch at http://server/repositiory/project/branches/branch
I understand this is an easy question but for some reason this just isn't
I understand I can create an enum like this: public enum MyEnum { ONE(1),
I have many short-lived branches in my workflow and I would like them to
I have 2 plain text files that contain some words, like: File 1 Aarhus

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.