Skip to content

Instantly share code, notes, and snippets.

@masci
Created September 25, 2014 09:23
Show Gist options
  • Save masci/1d9fa450c72089a29c2e to your computer and use it in GitHub Desktop.
Save masci/1d9fa450c72089a29c2e to your computer and use it in GitHub Desktop.
git rewrite path
PREFIX=projectA #adjust this
TAB=$'\t'
git filter-branch --index-filter '
git ls-files -s |
sed "s,${TAB},&"$PREFIX"/," |
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