Skip to content

Instantly share code, notes, and snippets.

@bcawrse
Forked from tduarte/publish-ghpages.md
Created July 26, 2020 23:19
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 bcawrse/347b4eafe470c6da429d9af12cce1a2e to your computer and use it in GitHub Desktop.
Save bcawrse/347b4eafe470c6da429d9af12cce1a2e to your computer and use it in GitHub Desktop.
If you need to force push an subtree
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
@bcawrse
Copy link
Author

bcawrse commented Jul 26, 2020

Notes from original

Thanks! This was great.

For anyone else stumbling on this, here are some pertinent doc links. Chances are you've seen this stuff, but subtree was new to me.

split overview
split options
push --force
branch -D

More concise approach:

git push origin `git subtree split --prefix dist master`:gh-pages --force

@bcawrse
Copy link
Author

bcawrse commented Jul 30, 2020

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