【发布时间】:2011-06-30 18:45:44
【问题描述】:
Github 有一个功能,您可以在其中放置 HTML 页面。 (Details here)。
无论如何,我最近使用它来放置上述页面。这样做的基本说明是:
// In order to create a new root branch, first ensure that your working directory is clean by committing or stashing any changes. The following operation will lose any uncommitted files! You might want to run this in a fresh clone of your repo.
$ cd /path/to/fancypants
$ git symbolic-ref HEAD refs/heads/gh-pages
$ rm .git/index
$ git clean -fdx
// After running this you’ll have an empty working directory (don’t worry, your main repo is still on the master branch). Now you can create some content in this branch and push it to GitHub. For example:
$ echo "My GitHub Page" > index.html
$ git add .
$ git commit -a -m "First pages commit"
$ git push origin gh-pages
所以一切顺利;正如所宣传的那样,我未跟踪的文件已被擦除,但我制作了该目录的副本,然后将必要的内容移回了原处。在分支之间来回切换(我使用 SmartGit)似乎不会擦除未跟踪的文件。
但是,我有兴趣扩展我对 Git 的基本知识,并且想知道为什么在第一次设置 gh-pages 时需要擦除未跟踪的文件。我原以为可以设置 gh-pages 分支,将 html 文件添加并提交给它并推送它,所有这些都不会影响未跟踪的文件。然后就切换回原来的分支。
【问题讨论】:
标签: git github git-branch