git bash - git filter-branch --subdirectory-filter fails with "Bad file number - could not get commits" -


I am trying to transfer a subdirectory to my GIT repo so that a new repository can be created (existing history protection). / P>

After various suggestions for this online, I have cloned the existing repo, removed the remote, and now want to use the GT filter-branch command which I want to exclude from the directory To snatch everything from the repo. But when I run the command, I get an error. / g> / git-core \ git-filter-branch: line 269: / libexe c / git-core / git: could not obtain bad file number command

I I am using git-bash on Windows

Looking at the source for git-filter-branch, this problem occurs when trying to run this command:

  git rev-list --reverse --topord - default head \ --parents - simply-merge $ rev_args "$ @" & gt; ../revs || Die "Could not Get Commit"  

I can run this order without any problem myself - depending on what option I have for $ rev_args value. When I am in a single commit, then all is well. But in the script, it comes from here:

  rev_args = $ (git rev-parse --revs-only "$ @")  

I run that command, I get a string with several thousand commit id.

So I suspect that the problem is that the script is trying to run, just too long to handle the shell, as a result I saw in a secret error message.

Is this analysis accurate? If so, what should I do about it?

I have got an alternative solution which I will post below, but it seems quite a hack and I hope that someone knows better. I got a git-filter-branch on my PC (this is / libexec / git-core / git- Filter-to-branch, using GIT-bash on windows)

Remarks out of lines 287- 9 (comment code) .... die "can not get commission" )

Replace with: $ rev_args do git rev-list --reverse --topo-order --default HEAD \ $ for rev

 < Code> rm ../revs --parents --simplify- Merge $ rev "$ @" & gt; & Gt; ../revs done  

Then I could run my git filter-branch --subdirectory-filter myDirectory - --all command and all is OK .

So, it seems a very awesome hack.

  • Is there a better way?
  • If not, then you this method?

Thank you!


Comments