Skip to content

Instantly share code, notes, and snippets.

@ViktorHofer
Last active December 12, 2020 10:08
Show Gist options
  • Save ViktorHofer/6d24f62abdcddb518b4966ead5ef3783 to your computer and use it in GitHub Desktop.
Save ViktorHofer/6d24f62abdcddb518b4966ead5ef3783 to your computer and use it in GitHub Desktop.
Update PRs with files changed in src/coreclr/src/*
# BACKUP your repo before doing this in case something goes wrong
# This isn't tested with commit ranges that include merge commits. Use with caution!
# Requires a Unix shell terminal
# REPLACE #START_COMMIT# with the SHA of the commit BEFORE (parent of) your first commit that you want to update.
# You need to git push --force to your branch after you validated that the commits are correct.
# Usage example:
# cd runtime
# vi script.sh (add content)
# chmod +x rewrite.sh
# Replace #START_COMMIT# with the SHA before your first commit.
# ./rewrite.sh
# rm rewrite.sh
# Validate changes in the tree!
# git push -f (to your branch!)
git filter-branch --index-filter '
git ls-files -s |
perl -0pe "s{src/coreclr/src}{src/coreclr}" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
' -f -- #START_COMMIT#..HEAD
@naricc
Copy link

naricc commented Dec 9, 2020

Do I want to start a rebase before using this?

@ViktorHofer
Copy link
Author

No, that command should be executed outside of any (pending) rebase operation.

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