Skip to content

Instantly share code, notes, and snippets.

@GuiltyDolphin
Created November 21, 2015 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GuiltyDolphin/6c2ae5c5b31eb1f1916f to your computer and use it in GitHub Desktop.
Save GuiltyDolphin/6c2ae5c5b31eb1f1916f to your computer and use it in GitHub Desktop.
Move files out of sub-directory in git.
git filter-branch --index-filter \
'git ls-files -s | sed -r "s-(\t\"*)DIRNAME/(.*)-\1\2-" | \
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment