Created
February 21, 2015 11:19
-
-
Save iluwatar/9f994a92c3c4ebda440c to your computer and use it in GitHub Desktop.
git_rewrite_history
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git filter-branch --index-filter \ | |
'git ls-files -s | sed "s-\t\"*-&myfolder/-" | | |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ | |
git update-index --index-info && | |
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE" | |
' --tag-name-filter cat -f -- --all |
Got it working with this instead!
git filter-branch --index-filter \
'git ls-files -s | sed -E "s/( [a-z0-9]{40} 0.)/\1first\//" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
' --tag-name-filter cat -f -- --all
I also had a problem with empty git commits. Therefore I added a check for those situations
git filter-branch --index-filter \
'git ls-files -s | sed -E "s/( [a-z0-9]{40} 0.)/\1ios\//" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
if [ -f "$GIT_INDEX_FILE.new" ]; then mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"; fi
' --tag-name-filter cat -f -- --all
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm on a mac and have a problem with that tab character...
I expected