tags:

views:

72

answers:

2

Here's an interesting experiment with using Git. Think of Github's ‘pages’ feature: I write a program in one branch (e.g. master), and a documentation website is kept in another, entirely unrelated branch (e.g. gh-pages).

I can generate documentation in HTML format from the code in my master-branch, but I want to publish this as part of my documentation website in the gh-pages branch.

How could I intelligently generate my docs from my code in master, move it to my gh-pages branch and commit the changes there? Should I use a post-commit hook or something? Would this be a good idea, or is it utterly foolish?

+2  A: 

You could 'git stash' your generated files and apply then on the relevant branch

git checkout master
#generate doc
git stash save
git checkout gh-pages
git stash pop
VonC
I hadn't thought of stashes yet, that looks neat. Would it be possible to automate it, for example a hook that runs before I create a tag or something?
avdgaag
+1  A: 

What would be the advantage of having generated files under version control? And if you insist on this, what would be the advantage of having generating and generated files in the same repository? git's branching support is fantastic, but I am sure it wasn't designed to do what you are trying to do.

innaM
I agree, since this `gh-pages` branch is actually a separate project, not really a branch of the main code base. It would be a hack. Still I'm curious if it can be done.
avdgaag
The Git repository of Git itself does exactly that (for man pages and stuff) so if they do it it must be right! :)
Bombe