Git branch experiment

六月ゝ 毕业季﹏ 提交于 2019-12-08 04:52:56

问题


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?


回答1:


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.




回答2:


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):

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



来源:https://stackoverflow.com/questions/1428766/git-branch-experiment

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