1

I trying to move some files with their history from one repository to another. There are many topics which discuss this, but i hit some problems which I did not see mentioned yet.

So the steps i do are:

git clone --no-local --no-hardlinks /path/to/origninal-rep repA  
cd repA
git remote rm origin 
git filter-branch -f --prune-empty --index-filter "git rm --cached --ignore-unmatch $(git ls-files | grep -v 'include/file1.h\|include/file2.h')"

with an intention to keep history related only to those two files and move them to another repository. However, i hit the following problem:

Rewrite 6768c299b2b25754a558336e025ce92576c954f2 (1/200)/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-filter-branch: line 329: CMakeLists.txt: command not found ....

Strangely enough i can remove files one-by-one, this works for example:

git filter-branch -f --prune-empty --index-filter 'git rm --cached --ignore-unmatch .gitignore' HEAD 

I also tried this on the dummy repository (with only couple of files) and everything worked fine! So it does not work in real life, perhaps somewhat related to the length of the output of git ls-files?..

UPDATE: I keep looking for solution, i wonder what should be the output of git ls-files? I have files listed with line breaks (1 file per line), whereas it seems that git rm should have files in one line, e.g. :

git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_1/* DIR_2/*' HEAD

could that be a problem?

UPDATE2:

I followed this solution to achieve the goal, everything worked.

Community
  • 1
  • 1
Denis
  • 1,526
  • 6
  • 24
  • 40
  • I have tried a similar operation on an OSX environment. Would you have permission issues on the problematic files? What Git version is it? (not sure how to help at this point) – Eric Platon Feb 20 '14 at 16:18
  • @EricPlaton i updated the question with some details, maybe that makes more sense now... – Denis Feb 20 '14 at 16:29
  • Cool that you solved the problem. A bit surprised if the problem is really the file list length, as the `ls-files` output is pipped and reduced to a couple files. Note that `'include/file1.h\|include/file2.h'` contains a backslash before the or. Was it intended? – Eric Platon Feb 21 '14 at 04:08
  • 1
    @EricPlaton i think that's the grep way of doing it. Alternatively one could do two greps: `| grep -v 'file.1' | grep -v 'file.2.'`, i suppose. But i have not checked it. – Denis Feb 21 '14 at 09:19

0 Answers0