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

  • Home
  • SEARCH
  • 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 6133083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:10:52+00:00 2026-05-23T17:10:52+00:00

I’m working with a branch that I need to split up in two branches:

  • 0

I’m working with a branch that I need to split up in two branches: Commits touching files in a specified list of directories go on one branch, the remaining commits go on the other branch.

Now, my idea was to use interactive rebase for that.

To get the first branch, I’d do this:

git log --format="pick %h %s" --reverse -- <dir-list>

and paste the result of that into the editor opened for the interactive rebase.

But then, to get the second branch, I’d have to maintain the opposite for all the other directories in my repo.

Is there a way to get the list of “opposite commits” somehow, or is there another, easier, solution to my problem?

  • 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-23T17:10:53+00:00Added an answer on May 23, 2026 at 5:10 pm
    git log --format="pick %h %s" --reverse -- dir1/ dir2/
    

    could be written

    git log --format="pick %h %s" --no-walk \
        $(git rev-list --reverse -- dir1/ dir2/)
    

    That is, using

    git rev-list HEAD -- dir1/ dir2/
    

    to get the list of ‘raw’ revision ids. Now to get the complementary set of revision ids, I suggest something like

    sort  <(git rev-list HEAD) <(git rev-list HEAD -- dir1/ dir2/) | uniq -u
    

    Integrating it all

    the complementary set would become

    git log --format="pick %h %s" --no-walk \
        $(git rev-list --no-walk --reverse \
           $(sort <(git rev-list HEAD) \
                   <(git rev-list HEAD -- dir1/ dir2/) | 
              uniq -u))
    

    note both --no-walk parameters there, they are crucial

    Recommendations

    1. I highly recommend making bash functions or scripts to implement the substeps here
    2. If you are just looking for a way to split repositories, look into git-filter-branch instead!
      • it will enable you ‘mask’ (remove) the unwanted part of the tree for each revision
      • allows you to skip effectively empty revisions, like you want
      • the man page contains samples for just that
      • it will work (correctly) if a single commit edited both parts of the repo
      • remember the --tag-name-filter cat option
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to create an if statement in PHP that prevents a single post

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.