Reputation: 7858
I have created a GitHub javascript project and after having the source in a proper shape, I had later on created the github pages for the project as well. This created, alongside my master
branch, a new gh-pages
branch in which the content of these pages are going to be.
Now, I want to display my project working as a demo in those same pages. I had already created a copy of the relevant part of the source, but I find that every time I make a change, I need to make the change on both sides (master
and gh-pages
), or what is worse: merge the changes ignoring most of the non-relevant commits (e.g., unit tests).
I have seen subtrees as a way to keep changes synchronized across multiple repositories, but I don't fully understand if it would apply on my case and how.
How can I achieve having a single folder synchronized across two branches?
Thanks!
Upvotes: 0
Views: 739
Reputation: 60275
I you'd rather not check out the gh-pages branch (e.g. avoid having to stash), you can
git commit-tree -p gh-pages -m "" master:html \
| xargs git update-ref refs/heads/gh-pages
Upvotes: 0
Reputation: 7642
You can checkout a particular file or folder from a specific branch or commit like this
//current branch: gh-pages
git checkout master yourfolder/
This checks out the particular folder you want to sync from the master branch to your gh-pages.
Now, you can commit with only the changes in that particular folder.
Upvotes: 1