synchronize git branch with master, selectively
I know how to “synchronize” two branches (i.e. the gh-pages branch is updated everytime the master is updated).
What I would like is to sinchronize only a certain directory of master to the gh-pages branch. To be clear, that’s what I would like to achieve:
+-- some | +-- file | +-- here | +-- dist/ | +-- some_other | +-- dist_file
+-- some_other | +-- dist_file
In other words, I’d like to have gh-pages updated as the dist/ directory of master every time master gets pushed.
Is it feasible?
One Solution collect form web for “synchronize git branch with master, selectively”
Constructing the commit yourself is easy:
git commit-tree -p gh-pages -m "" master:dist \ | xargs git update-ref refs/heads/gh-pages
Automating that is just a matter of taste. Simplest is to just write a script and run that instead. Hooks are an inbound thing for vetting what you’re doing to your repo; pushing untested repo changes isn’t something git’s really set up to automate. As I recall github doesn’t do hooks at all, so if you want a receive hook on stuff you push there, just make a proxy repo and have the hook do your synch and forward the push.