管理代码&文档在同一个git目录结构中 [英] managing code & documentation in the same git directory structure

查看:89
本文介绍了管理代码&文档在同一个git目录结构中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个项目从谷歌代码转移到了Github。这个项目在一个目录结构中包含代码和文档。



我想用Github的Pages功能来托管 html 文档。理想情况下,我想要执行1 push 来更改代码&文档。



我该如何做到这一点? 来到



您最终可以在一个分支中更新代码和页面。


I transferred a project from Google Code to Github. This project contained, in one directory structure, both code and documentation.

I'd like to use the "Pages" functionality of Github to host html documentation. Ideally, I'd like to do 1 push to commit changes to code & documentation.

How can I achieve this?

解决方案

When it comes to GitHub pages, you have user pages and project pages.
I will suppose you are speaking of the latter, which means you need to create your own gh-pages branch, copy your documentation files from your master branch in this new empty branch, as described in the GitHub doc page.

From there, when you have new commits both in your master and gh-pages branches, you can push both branches in one push (git push --all)

The problems start when you absolutely want to see both directory structures at the same time.
The simplest solution is:

  • one clone of your repo set on the master branch.
  • one clone (of the same repo) on the gh-pages branches.
  • a symlink from the first repo to the second repo (which allows you to make modifications on code and doc in the same directory structure. Symlinks are even supported on Windows since Vista).
  • a git alias script in order to automate the command sequence 'git push master origin; cd ../secondRepo; git push gh-pages origin'

You can try to get a doc repo as a submodule of your main repo, but... that seems way more complex that it ought to: see "How to add a git repo as a submodule of itself? (Or: How to generate GitHub Pages programmatically?)".


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 finally can update both code and pages in one branch.

这篇关于管理代码&文档在同一个git目录结构中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆