gpt4 book ai didi

angularjs - 如何将我的 AngularJS 静态站点上传到 Github Pages?

转载 作者:行者123 更新时间:2023-12-04 00:58:40 25 4
gpt4 key购买 nike

我已经用 AngularJS 创建了一个静态站点,现在想将它作为 Github 页面上传。我已按照此处的所有说明进行操作

https://help.github.com/articles/creating-project-pages-manually

我可以创建一个名为 gh-pages 的新分支和 git push origin gh-pages我所有的内容都很好。当我去我的仓库时,我看到了新的 gh-pages像这样将所有文件分支到那里

https://github.com/siddhion/maxmythic_angular/tree/gh-pages

问题是当我尝试在 http://siddhion.github.io/maxmythic_angular/ 查看我的网站时我只是得到一个 404 页面。我认为问题在于我没有 index.html在顶级目录中。它实际上位于app目录。我的目录结构看起来像它的样子,因为我是通过 Yeoman 创建的。我假设我需要顶级的所有文件。或者也许我在这个假设中错了?

如何让我的 AngularJS 静态站点正确显示?

更新

我按照斯蒂芬提供的步骤进行了操作。我到了第 3 步,但出现错误:

$ git subtree push --prefix dist origin gh-pages
git push using: origin gh-pages
To git@github.com:siddhion/maxmythic_angular.git
! [rejected] 5db3233d7c0822eedc5500409ce6a2d4b73ad427 -> gh-pages (non-fast-forward)
error: failed to push some refs to 'git@github.com:siddhion/maxmythic_angular.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

然后我尝试
$ git pull origin master
From github.com:siddhion/maxmythic_angular
* branch master -> FETCH_HEAD
Already up-to-date.

然后尝试 git subtree push --prefix dist origin gh-pages再次但得到了同样的错误。

在 Yeoman 部署页面,我在 下看到一些常见错误 部分

You might get an error like this Updates were rejected because the tip of your current branch is behind. You can solve this by force pushing to the remote (be careful though, it will destroy whatever is already there).



我很担心强制 subtree push因为我是 git 的新手,不知道什么会被破坏。我的意思是,我目前没有 gh-pages在我的 maxmythic_angular 分支 origin远程所以我不担心,但我有我的 master , gh-pages-oldgh-pages-v1那里的分支机构。如果我运行 git subtree push --prefix dist origin gh-pages,它们会被摧毁吗? ?

最佳答案

有一个deployment guide在 Yeoman 的网站上,了解如何使用 git subtree 部署到 gh-pages 分支。 .

从指南...

当您运行 grunt build 时,它会在可以部署的 dist 目录中生成一个完全优化的应用程序版本。

部署 dist 目录的推荐方式是使用 git subtree。

  • 从 .gitignore 文件中删除 dist 目录。
  • 将 dist 目录添加到您的存储库并将其与您的项目一起提交。
    git add dist && git commit -m "Initial dist subtree commit"
  • 一旦 dist 目录成为您项目的一部分,我们就可以使用 git subtree 在不同的分支上设置一个单独的存储库。注意:prefix 必须是你的 dist 目录的相对路径。这是假设 dist 在您的根目录中。
    git subtree push --prefix dist origin gh-pages
  • 现在,您可以在默认(主)分支中提交整个存储库,并且只要您想部署 dist 目录,就可以运行:
    git subtree push --prefix dist origin gh-pages
  • 关于angularjs - 如何将我的 AngularJS 静态站点上传到 Github Pages?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17643381/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com