Reputation: 521
I'm trying GitHub pages with a webpack project, so I made a new branch (forgot to use --orphan
) and keep different files in them.
master
branch, dist/
directory is .gitignore
d.gh-pages
branch, all files are ignored except for dist/
, index.html
and some other files. When I npm run build
on master
, the new dist/
is built, but it is overwritten by the former dist/
when I checkout gh-pages
. How to keep them and make it possible to add and commit them after?
Upvotes: 3
Views: 201
Reputation: 521
Despite the better practice here, I have found a way to do the file transferring directly.
master
branch, after committing everything and doing the build;git add --force dist/
git stash
git checkout gh-pages
git stash apply
.gitignore
in case it is also transferred However, it requires too many steps to be useful, and maybe simply cp
them would be much easier.
Upvotes: 0
Reputation: 1324935
Regarding the possibility of using two separate worktrees, you can use the git worktree
command: that avoids having to maintain two different clones.
Don't forget also "Simpler GitHub Pages publishing": you can maintain your pages in the same branch as the rest of your repo, in a docs/
sub-folder.
That way, you don't need to switch branches at all.
Upvotes: 1