【问题标题】:cannot update github pages with subtree push无法使用子树推送更新 github 页面
【发布时间】:2017-07-28 06:23:23
【问题描述】:

我无法推送到我的 gh-pages 分支。

我有一个组织帐户,其中包含服务器和客户端代码(尽管我认为这并不重要)。所以结构是这样的:

my-org
   my-repo
      client
         src
      server
         src

这就是我重现问题的方式:

  • 在我的机器上创建一个新目录,以确保一切都是干净的
  • 将 repo 克隆到其中
  • 构建静态 Angular 应用程序 - 这将创建一个目录 /client/dist

我的目录现在包含以下内容:

my-repo
   client
      src
      dist <-- this is what I want to go into gh-pages branch
   server
      src

此目录中的文件希望通过 github 页面提供服务。所以我跑了

git subtree push --prefix client/dist origin gh-pages

然而这会输出:

git subtree push --prefix client/dist origin gh-pages
git push using:  origin gh-pages
To github.com:my-org/my-repo.git
 ! [rejected]        c7ac6936acbe0f5751755d60776074b98dae54d6 -> gh-pages (non-fast-forward)
error: failed to push some refs to 'git@github.com:my-repo/my-repo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate 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)什么都不做,

git pull on master 和 gh-pages 返回预期:

Already up-to-date.

我错过了什么? (我在 git 版本 2.10.1)

【问题讨论】:

  • gitk --all 提供什么信息?您是否在两个不同的位置看到 origin/gh-pagesgh-pagesdist/ 在您的 .gitignore 文件中吗?
  • dist/不在.gitignore中,而且只有一个gh-pages/remotes/origin/gh-pages——不过看起来有点奇怪,我去看看,谢谢指点我去 gitk!

标签: git github github-pages git-subtree


【解决方案1】:

如果 gh-pages 分支的唯一目的是构建你的 repo 中的内容,只需从 github 完全删除 gh-pages 分支,然后运行 ​​subtree push 命令

【讨论】:

    猜你喜欢
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 1970-01-01
    相关资源
    最近更新 更多