Laravel Undo Committed Published Assets

Sometimes you commit to a Git branch and you realize you did not want to commit the published JS and CSS files as well, but you did. Well there is a solution for that.

git reset --soft HEAD~1
git reset HEAD public/*
git commit -c ORIG_HEAD
git push --force

It will reset to 1 commit back in this case so you may need to change to more than that like my if you made more erroneous commits. Once that is done you can remove the static compiled assets from the commit using a git reset HEAD public .

Then you dod a new commit but using `ORIG_HEAD`. Once that is done you push with force so warnings that you are behind committed files on remote and update your branch.

NB I would not recommend this in master branch, but in a feature branch this works miracles!

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.