Skip to content

Instantly share code, notes, and snippets.

@samueljohn
Last active December 15, 2015 15:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueljohn/5280700 to your computer and use it in GitHub Desktop.
Save samueljohn/5280700 to your computer and use it in GitHub Desktop.
Moving homebrew formulae from one repo (mxcl/master) into another one... Based on @jacknagel's instructions.
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1048576`
cd $(brew --repository)
git checkout -b moveit
git filter-branch --prune-empty --index-filter 'git ls-files --full-name --cached | grep -F --invert-match --file=/tmp/list --color=never | xargs git rm --quiet --cached --ignore−unmatch' --subdirectory-filter 'Library/Formula' -d /Volumes/ramdisk -f moveit
cd the-target-repro
git fetch $(brew --repository)
git merge moveit
@samueljohn
Copy link
Author

The git ls-files --full-name --cached | grep -F --invert-match --file=/tmp/list --color=never part seems to work fine, it lists all files/dirs but not the formulae names listed in /tmp/list.

The output is something like:

rm: /Volumes/ramdisk: Resource busy
Rewrite b48bb58df7ba6dbe35a1d6d6c1d165ed957e97dc (9748/16197)

...and seems to succeed. I am not sure if the "Resource busy" is a problem or not.

@samueljohn
Copy link
Author

The ramdisk is populated with a temporary git repository during this process (so files are being written).

@samueljohn
Copy link
Author

I guess I know what is going on ... the xargs has a unnecessary -0 in my case.

@samueljohn
Copy link
Author

updated the gist

@adamv
Copy link

adamv commented Aug 31, 2013

Where is the file to keep specified?

@samueljohn
Copy link
Author

The files to move are in /tmp/files in this example. I should update the gist with a line to populate that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment