git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
Last active
October 5, 2025 09:29
-
Star
(125)
You must be signed in to star a gist -
Fork
(22)
You must be signed in to fork a gist
-
-
Save tduarte/eac064b4778711b116bb827f8c9bef7b to your computer and use it in GitHub Desktop.
If you need to force push an subtree
This all requires that dist is already committed to master. Is it possible to just push something not committed?
very nice, sir!
I love this, but it would be nice if the local and remote branches weren't named the same in your example - I can never remember what order gh-pages:gh-pages is :)
More concise approach:
git push origin `git subtree split --prefix dist master`:gh-pages --force
For those using fish shell:
git push origin (git subtree split --prefix dist master):gh-pages --force
much amz very
This is amazing thank you!!!
brilliant thanks! :)
still here, thank you again
git push origin
git subtree split --prefix dist master:gh-pages --force
Thank you so much! 🫶🏻
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is perfect. Thanks.