1

My situation is thus:

I do work on two different machines, both of which track a repository (origin) cloned from another source (git.domain_name).

One one machine, my_machine1, I've created a branch to add some functionality, we'll call it myFoo.

One the other machine (my_machine2), I'd like to track (and be able to update and push to my_machine1) the myFoo branch.

On my_machine2, I've done git remote add my_machine1 my_user@my_machine1:/path/to/common/repo

But if I do a git branch -a I don't see any branches from my_machine1, only from origin. I can see branches on my_machine1 if I do a git ls-branch my_machine1. Pushing myFoo to origin is not an option.

Is there some way to track/share the myFoo branch between my_machine1 and my_machine2?

alesplin
  • 1,332
  • 14
  • 23

3 Answers3

2

In addition to the suggested git fetch, "git remote update" works too (will fetch all remotes).

Also, the -f option to git add does the fetch just after the add, which is great to check that there are no mistakes in the newly added remote

sylvain.joyeux
  • 1,659
  • 11
  • 14
1

Adding a remote doesn't fetch the stuff, you still have to git fetch my_machine1

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • 1
    alternatlively, "git remote update" works too. The -f option to git add does the fetch just after the add, which is great to check that there are no mistakes in the newly added remote. – sylvain.joyeux Sep 24 '12 at 20:32
1

Note: git remote update will always fetch all the remotes, like a git fetch --all would (see "git remote update")

As mentioned in "What is the difference between git fetch origin and git remote update origin?", remote update is a very high-level command

  • it supports grouped remotes (remotes.<group> = <list>),
  • and updating all remotes (except those with remote.<name>.skipDefaultUpdate set),
  • but not any of the more specific options of fetch.

Git fetch also supports groups of repos:

$ git config remotes.mygroup 'remote1 remote2 ...'
$ git fetch mygroup

So for just one remote repo (origin), git fetch is both more precise and offers more options than git remote update.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250