Is it possible to add a hook to a git repo that will automatically copy files from a directory in master to the root of a branch?
Here’s the reason:
I’d like to use GitHub pages to publish project documentation. Unfortunately, GitHub insists that the site content be in a branch named “gh_pages”. The trouble with this is that I have to switch branches whenever I want to write documentation, so I can’t code and write at the same time. Also, Eclipse freaks out when I switch to the gh_pages branch because there’s no .project file there, so the whole project closes.
A better way would be to store site content in a /gh_pages subdirectory in the master branch. It would be very cool if I could just edit a few markdown pages there, commit and push, and have to site be updated automagically.
Possible?
yes. you can add a folder within your project and have it as a submodule of itself. Point the submodule to the gh_pages branch. What’s more, is now you have a versioned link between the 2.
Here are he steps:
when you update your docs, execute this
I don’t bother scripting this. Pressing
CTRL-Rand typedocswill bring it up quickly. Hit enter and you’re good to go.when you run
git statusyou will see that there is a folder with changesdocs. Add and commit as usual.When others want to keep in sync, you need to issue the command
to see whether the docs needs to be updated,
will show you if the submodule is up to date or not initialized. If it’s up to date and initialized, you will see no marker before it’s listing. Otherwise, it will have a
+or-in front of it depending if it’s behind or in front of the version that the top level repo has registered in the current commit.More info can be found in the progit.org/book chapter 6, section 6.