avdgaag
avdgaag

Reputation: 42142

Git branch experiment

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?

Upvotes: 1

Views: 455

Answers (2)

VonC
VonC

Reputation: 1326872

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

Update August 2016: Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more gh-pages needed):

Now you can select a source in your repository settings and GitHub Pages will look for your content there.

You can now keep your doc up-to-date with your code in a subfolder of the same branch.

Upvotes: 2

innaM
innaM

Reputation: 47869

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.

Upvotes: 1

Related Questions