我尝试将我的Yeoman AngularJS静态站点部署到Github页面,但git子树命令总是被拒绝

时间:2013-07-23 21:34:38

标签: angularjs github yeoman github-pages git-subtree

我正在尝试将我的AngularJS静态站点(我从Yeoman开始)部署为Github页面,并按照Yeoman deployment guide中提供的步骤进行操作。我在步骤1和2中取得了成功,但是当我到达第3步时,事情就变得糟糕了。第3步告诉我运行

git subtree push --prefix dist origin gh-pages

当我跑步时,这就是我所看到的

$ 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部署页面,我看到一些常见错误部分

  

您可能会收到类似的错误因为提示而拒绝更新   目前的分支机构落后了。你可以通过强制推动解决这个问题   到遥远的地方(但要小心,它会破坏已经存在的东西   有)。

我很担心强迫subtree push,因为我一般都是git的新手,不知道会被摧毁的是什么。我的意思是,我目前在我的maxmythic_angular gh-pages遥控器上没有origin分支,所以我并不担心,但我有mastergh-pages-old和{{1那里的分支。如果我运行gh-pages-v1,它们会被销毁吗?

更新

我继续将我的工作复制到另一个文件夹是安全的,我将git subtree push --prefix dist origin gh-pages添加到我的--force命令并运行它。这就是我得到的

git subtree push

如何才能使用 $ git subtree push --prefix dist origin gh-pages --force error: unknown option `force' usage: git subtree add --prefix=<prefix> <commit> or: git subtree add --prefix=<prefix> <repository> <commit> or: git subtree merge --prefix=<prefix> <commit> or: git subtree pull --prefix=<prefix> <repository> <refspec...> or: git subtree push --prefix=<prefix> <repository> <refspec...> or: git subtree split --prefix=<prefix> <commit...> -h, --help show the help -q quiet -d show debug messages -P, --prefix ... the name of the subdir to split out -m, --message ... use the given message as the commit message for the merge commit options for 'split' --annotate ... add a prefix to commit message of new commits -b, --branch ... create a new branch from the split subtree --ignore-joins ignore prior --rejoin commits --onto ... try connecting new tree to an existing one --rejoin merge the new branch back into HEAD options for 'add', 'merge', 'pull' and 'push' --squash merge subtree changes as a single commit 命令,以便将网站部署到gh-pages?

更新

我想看看这个问题是否与说明有关,或者只是与我的回购有关,所以我设置了一个新的Angular应用程序git subtree push --prefix dist origin gh-pages并遵循部署说明。 yo angular这次工作了。我仍然不知道我的gh-pages repo发生了什么。我必须真正地了解git subtree push进出。

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。问题是我已经在当前的回购中承诺了dist。不作为子树。以下步骤应解决问题

// remove the dist and commit
rd  /s dist
git commit -am "remove dist folder"
// add the subtree and push
git subtree add --prefix dist origin gh-pages
git subtree push --prefix dist origin gh-pages

这似乎为我做了伎俩

答案 1 :(得分:0)

我还使用了子树方法一段时间将典型的Yeoman dist文件夹推送到远程(在我的情况下是gh-pages)。它是一个make make但在服务器上发生变化时会引起头痛。 然后,您必须采用上面描述的不那么优雅的解决方案。正如你所注意到的那样,那些会产生更多的麻烦。我相信这个特殊的工作流程,使用子树方法就是黑客攻击。

这是一个更好的解决方案:Rob Wierzbowski grunt-build-control。需要10分钟才能安装,但工作方式就像魅力一样,整个部署构建文件夹到遥控器变得自动化。完全版本控制和无痛。

现在也在Yeoman wiki中提及。