Is cross-branch reference possible?

元气小坏坏 提交于 2019-12-24 16:01:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!