1

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:

master:

+-- some
|
+-- file
|
+-- here
|
+-- dist/
    |
    +-- some_other
    |
    +-- dist_file

gh-pages:

+-- 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?

Community
  • 1
  • 1
janesconference
  • 6,333
  • 8
  • 55
  • 73

1 Answers1

1

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.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • No, you said you already know how to do the automation so I left that out. – jthill Jul 10 '13 at 13:54
  • I know that putting `push = +refs/heads/master:refs/heads/gh-pages push = +refs/heads/master:refs/heads/master` in .git/config will synchronize the two branches, I really don't know if it works with your method – janesconference Jul 10 '13 at 14:06