Skip to content

Instantly share code, notes, and snippets.

@bahmutov
Created December 16, 2014 18:53
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 bahmutov/3d59a57d91e1d9b772f5 to your computer and use it in GitHub Desktop.
Save bahmutov/3d59a57d91e1d9b772f5 to your computer and use it in GitHub Desktop.
Adds file into old commit (and all commits after that)
file_path=bower_components/angular-bindonce/bindonce.js
before_commit=$(git rev-parse --verify 14f0b9d)
file_blob=$(git hash-object -w "$file_path")
echo "before commit $before_commit"
echo "file blog $file_blob"
git filter-branch \
--index-filter '
if x=$(git rev-list -1 "$GIT_COMMIT" --not '"$before_commit"') &&
test -n "$x"; then
git update-index --add --cacheinfo 100644 '"$file_blob $file_path"'
fi
' \
--tag-name-filter cat \
-- --all
git reset --hard
@bahmutov
Copy link
Author

Could double all newer commits, use with caution

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