问题
I have a personal project on Github. My main documentation is a bunch of text files in my master branch, and I automatically generate some HTML pages from them. Github keeps the webpage for the repo in a separate branch called gh-pages. I want that page to refer my generated html files. Is it possible to hardlink/import a file on an another branch, so that when I change my docs in master and rebiuld the html files, gh-pages branch is also up to date?
回答1:
You have two different points here:
- first, auto-generated files have to be put into the git repository.
- second, you want to have them in another branch.
My take would be to have two local repositories tracking both branches (master and gh-pages), and let your generating process put the generated files from master into the working directory of gh-pages. Then use a series of git add, git commit and git push in the second repository to have the online gh-pages updated.
Actually, I just tried this, with not two complete local repositories, but one repository with two working directories, using git-new-workdir. Then a symlink (not versioned, but ignored) from master/javadoc to gh-pages/javadoc), to create the documentation at the right location.
(The result is my jsch-documentation repository.)
回答2:
You'll need to manually track the files from the master branch to the gh-pages branch. But this should be simple to do by writing a quick script around either ''git merge'' or more likely ''git cherry-pick'' that you can run immediately after committing your changes to master.
回答3:
Or you can use a submodule and check out the desired version of the submodule.
Also if you don't mind writing a little script you can do a clean/smudge filter that will expand a kind of 'keywords' in your sources with the actual reference values you need automatically on checkout/checkin
See http://progit.org/book/ch7-2.html (man gitattributes); Not to sure whether github allows you to execute any hooks or attibute filters. Check their FAQ, I suppose
来源:https://stackoverflow.com/questions/5290760/is-cross-branch-reference-possible