[<<][git][>>][..]
Tue Jun 21 14:30:36 CEST 2011

Tracking branches and origin

I'm completely confused now.  What I understand is the following: it's
straightforward to have a local branch and push it to a remote one,
but creating a tracking branch seems to fail.

Aha, I had a missing "fetch =" line in my .git/config

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = <....>

With this, a "git pull" will indeed pull in the remote refs.

So, to link a local branch to a tracking branch do something like this:

  git config branch.dev.remote origin
  git config branch.dev.merge  refs/heads/perso/tschoute/dev

This will end up in .git/config as:

[branch "dev"]
        remote = origin
        merge = refs/heads/perso/tschoute/dev


Now, "git pull" seems to pull in changes from the tracked branch, but
"git push" doesn't push.  Why is that?  It seems that pushes always
need to be explicit, i.e. tracking is really only for pull.  So in the
case above, a push is

  git push origin HEAD:perso/tschoute/dev

Or, alternatively, to push it to the trackin branch using a more
general command:

  git push origin HEAD:$(git config branch.dev.merge)




[Reply][About]
[<<][git][>>][..]