为什么git不会推送到本地repo更新头?

时间:2012-01-01 20:44:24

标签: git

我有一个本地回购upstream和一个downstream克隆了它。 upstream有一个名为receiving的非主分支我用于推送(两个代理都没有)。

当我执行git push origin origin/receiving时,git正确地推送提交对象但不更新upstream中的HEAD。我之前通过打开编辑器中的文件并手动更新哈希来解决问题。我还是想知道我能做些什么来让它自动化。没有任何权限问题 - 我实际上是以root用户身份完成这些回购。

2 个答案:

答案 0 :(得分:2)

我认为你的推送命令是错误的。您想要推送本地分支receiving(或您称之为的任何内容:

git push origin receiving:receiving

这绝对有效,这是一个例子:

$ git init upstream
$ cd upstream
$ touch foo && git add foo && git commit -m 'initial'
$ git branch receiving
$ cd ..
$ git clone upstream downstream
$ cd downstream
$ >foo echo "downstream change" && git commit -am 'downstream'
$ git push origin master:receiving
$ cd ../upstream
$ git show receiving --
commit …
Author: …
Date:   Sun Feb 26 13:40:02 2012 +0100

    downstream

diff --git a/foo b/foo
index e69de29..2ba104f 100644
--- a/foo
+++ b/foo
@@ -0,0 +1 @@
+downstream change
$ git log --oneline --decorate --graph --all
* deadbeef (receiving) downstream
* c0ffee11 (HEAD, master) initial
$

答案 1 :(得分:0)

您必须git push origin receiving而不是git push origin origin/receiving