1

I've got a local repo upstream and a downstream cloned from it. upstream has a non-master branch called receiving I use for pushing (neither repo is bare).

When I do git push origin origin/receiving, git properly pushes the commit objects over but doesn't update the HEADs in upstream. I've actually fixed the issue before by opening the files in my editor and manually updating the hash. I'd still like to to know if there's something I could do to make it automatic. There aren't any permission issues - I'm actually doing everything as root with these repos.

simont
  • 68,704
  • 18
  • 117
  • 136
ldrg
  • 4,150
  • 4
  • 43
  • 52
  • 1
    Related: http://stackoverflow.com/questions/2147741/git-push-only-for-bare-repositories - that branch you push to isn't the currently checked-out one is it? – Mat Jan 01 '12 at 20:58
  • No, I push to a branch "receiving" which is never checked out and exists only to receive pushes. – ldrg Jan 02 '12 at 23:46
  • 1
    Why do you push `origin/receiving`? That's the remote tracking branch and it should point to the same commit in both repositories (unless `upstream`'s `receiving` branch was updated and you have not fetched/pulled recently) – knittl Feb 26 '12 at 12:35

2 Answers2

2

I think your push command is wrong. You want to push the local branch receiving (or whatever you call it:

git push origin receiving:receiving

This should definitely work, here's an example:

$ 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
$
knittl
  • 246,190
  • 53
  • 318
  • 364
  • Thank you! I think it's also worth mentioning for anyone else who comes upon this to read up on refspecs in the manual page for git push. Had I understood refspecs I wouldn't have asked this question in the first place! – ldrg Mar 02 '12 at 06:38
0

You have to do git push origin receiving rather than git push origin origin/receiving

manojlds
  • 290,304
  • 63
  • 469
  • 417