不能推子树分支

时间:2011-03-08 21:40:55

标签: git

我有一个包含应用程序的git存储库,我想使用该repo的子目录来更新共享库存储库。我可以获取库repo,提交更新,但我无法将其提交回远程。它应该是一个快进的,但它说它不是。我做错了什么?

$ git remote add lib goertzen@minerva:/pub/shared_git_repositories/lib.git

$ git fetch
From minerva:/pub/shared_git_repositories/lib
 * [new branch]      master     -> lib/master

$ git checkout -b libmaster lib/master
Branch libmaster set up to track remote branch master from lib.
Switched to a new branch 'libmaster'

$ git merge --squash -s subtree -X theirs master
Auto-merging lib.yaml
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committing as requested

$ git commit -m "blah blah blah"
[libmaster 4949ef3] blah blah blah
 1 files changed, 148 insertions(+), 95 deletions(-)

$ git push lib
To goertzen@minerva:/pub/shared_git_repositories/lib.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'goertzen@minerva:/pub/shared_git_repositories/lib.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

$ git pull
Already up-to-date.

$ git log --graph --all --full-history --branches --decorate
* commit 4949ef3181c21d85340b9fb16af5f9c2c58e75ae (HEAD, libmaster)
| Author: <snip>
| Date:   Tue Mar 8 15:25:03 2011 -0600
|
|     minitransfer changes
|
* commit e2dca9e2bcd28d09a455e9cc662f7eb630a0adc2 (lib/master)
  Author: <snip>
  Date:   Thu Feb 24 10:54:31 2011 -0600

      initial commit of shared lib repo

* commit b70bde69e5c4ddb079d06d7310d415fa89764b95 (origin/master, origin/HEAD, master)
| Author: <snip>
| Date:   Fri Mar 4 15:41:05 2011 -0600
|
|     fix typo
|
* commit cc64b565fbb88729e16314f76867ab24c37bfc47
| Author: <snip>
| Date:   Fri Mar 4 15:38:59 2011 -0600
|
...

我可以用简单的编辑替换压缩的子树合并,但我仍然遇到同样的问题。

2 个答案:

答案 0 :(得分:7)

事实证明,“git push lib”实际上是试图将libmaster推送到origin / master而不是lib / master(我在一些牺牲回购中进行了实验)。当我把这一切详细拼写出来时......

git push lib libmaster:master

......它奏效了。

我当然希望能够在不必详细说明的情况下推动。这让我想知道我是否以奇怪的方式将lib带入了repo,或者我是否需要以某种方式配置分支。我有一些阅读要做...

答案 1 :(得分:0)

按照Git所说并先运行git pull ...