Skip to content

Instantly share code, notes, and snippets.

@bahmutov
Created December 16, 2014 18:53
Show Gist options
  • Select an option

  • Save bahmutov/3d59a57d91e1d9b772f5 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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