ele*_*ele 34 git git-subtree yeoman
我们使用子树部署这个Gist来部署我们的Yeoman项目的子目录.在我们的例子中,分支称为生产,而不是gh-pages.
直到昨天Git服务器拒绝了命令时git subtree push --prefix dist origin production,这种情况还算完美
! [rejected] 9fe1683aa574eae33ee6754aad702488e0bd37df -> production (non-fast-forward)
error: failed to push some refs to 'git@gitlab.sdstate.edu:web-and-new-media/graduation2015.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart.
Run Code Online (Sandbox Code Playgroud)
如果我在本地切换到生产分支(这是干净的),即使我使用该选项也会git pull返回.Your branch is up-to-date with 'origin/production'.--rebase
我可以通过我们的Web UI在服务器上看到生产分支的内容,并且没有什么不应该是,只是dist我期望的目录的编译输出.
为此,似乎我应该能够安全地强制覆盖这些文件,但是如何?git subtree push没有--force选择.
ele*_*ele 59
诀窍是将子树拆分为强制推送:
git push origin `git subtree split --prefix dist master`:production --force
Run Code Online (Sandbox Code Playgroud)
我从http://clontz.org/blog/2014/05/08/git-subtree-push-for-deployment/的附录中得到了这个,他实际上在Stack Overflow上引用了这个答案.我之前已经略过了这个,但Steve Clontz的帖子让我点击了它.
我刚刚增强了ele添加通用表达式的答案,<>使其更加清晰:
git push <remote> `git subtree split --prefix <local-folder> <local-branch>`:<remote-branch> --force
Run Code Online (Sandbox Code Playgroud)
示例值
<remote>
origin
other-origin-name
https://github.com/full-url/of-repo
Run Code Online (Sandbox Code Playgroud)
<local-folder>
相对于 repo root 的本地文件夹(在 root 中执行此命令),例如: /dist
<remote-branch>
master
any-other-branchname
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9659 次 |
| 最近记录: |