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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:56:04+00:00 2026-05-18T06:56:04+00:00

Say I introduced <feature.c> a while ago and now notice it shouldn’t have been

  • 0

Say I introduced <feature.c> a while ago and now notice it shouldn’t have been part of my main branch but rather a branch feature. Is it possible to use e.g. git-filter-branch to automatically move all of <feature.c>’s history out of my main branch into the feature branch?

  • 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-18T06:56:05+00:00Added an answer on May 18, 2026 at 6:56 am

    It sounds like you’re doing something fairly insane! 🙂

    That said, I see a few options, none of which are particularly automated.

    1. If you’ve got a ton of commits with that file present, just admit the mistake, make a new branch off of your HEAD, and put further commits with that feature into that branch until they’re stable. If you’re repo’s shared, this becomes the only real option. No one wants to have divergent history, especially if that feature was committed deep in the history.

    2. If you’re only talking about 10 or so commits that have actually touched that file, and they’re fairly recently committed without many other commits interleaved, you could check out a new branch on HEAD, and revert the branch you don’t want this feature in back to before you added the feature, and then cherry pick commits you need out of the feature branch until you’re ready to commit them all in at a later date.

    3. If you’re dealing with a ton of history, lots of interleaved commits, and you really don’t want to have that feature present at all, you could write up a little shell script that takes the output of git log and cherry picks it into a new branch. Something along the lines of:

      $ cd git-repo
      $ git checkout -b feature-x
      $ the-perfect-shell-script `git log --pretty=format:"%H" path/to/feature.c`
      

      Once you have that feature branch with all of the commits cherry picked out, you can then use git filter-branch to filter out all of the commits that reference that file. The man page has a simple example that does exactly that.

      Once you’ve got that, you can then git rebase feature-x --onto <filtered-branch> and you should be good to go.

      Of course that should be quite discouraged, especially if any of that is published.

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

Sidebar

Related Questions

Vista introduced tags for the files. But how to extract these tags, let's say
Say I have a table name auto_parts with these fields. id, part, price, timestamp
Recently a couple of WCF services have been introduced to our company's API. There
Let's say I have a file A.cpp, and I notice an error on line
say i have a git repo, with such commit history: A-B-C-D-E Now, suddenly i
Let's say I have an array of zeros: a = numpy.zeros(1000) I then introduce
Say I have this method public void test(IList<AvaliableFeaturesVm> vm) { } I have this
Say I have the following generic class: public class Foo<T extends Bar> { //
Say I have a method that returns this. Vector[ (PkgLine, Tree) ]() I want
Say I have an input consisting of 30 numbers, and I want the 1st,

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.