You can use the subdirectory filter to achieve this
$ git filter-branch --subdirectory-filter blog/ -- --all
EDIT 1: If you don’t want to effectively make _posts
the root, use a tree-filter instead:
$ git filter-branch --tree-filter 'mv blog/_posts .' HEAD
EDIT 2: If blog/_posts
did not exist in some of the commits, the above will fail. Use this instead:
$ git filter-branch --tree-filter 'test -d blog/_posts && mv blog/_posts . || echo "Nothing to do"' HEAD