Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the master branch track?

Tags:

git

I cloned a repository and was working in the master branch. There was a consistent problem: git push (and git push) didn't work and gave long, uninterpretable error message. Through trial-and-error, I found git push origin master did the push correctly. But now I've noticed something odd:

$ git config push.default tracking
$ git push
fatal: The current branch master is not tracking anything.

WTF? I thought if you cloned a repository, the master was automatically tracked. Anyway, my real questions are

  1. How am I supposed to create a clone so the branches are tracked?
  2. What are the consequences (other than current) of not having tracking?
  3. How do I fix the current situation, so that my branch does track the remote?

EDIT My local repository was acting strangely in other ways; most notably: I couldn't create remote branches. I put it aside and made a fresh clone, and it's acting strangely in fresh ways.

First, master is tracking (yeah). Second, I was able to make a remote branch, but it's odd.

Ratatouille $ git push origin origin:refs/heads/premium
Total 0 (delta 0), reused 0 (delta 0)
To [email protected]:gamecrush/Ratatouille.git
 * [new branch]      origin/HEAD -> premium
Ratatouille $ git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/premium

Ratatouille is the name of the remote repo, of course. The strange point: what is that -> there for? It seems to be new and it doesn't show up for the old local repo or other clones of the remote.

But now branching and tracking work as advertised.

like image 252
Michael Lorton Avatar asked Feb 25 '11 00:02

Michael Lorton


3 Answers

Other alternative:

git branch --set-upstream-to=origin/master
like image 43
Arturo Herrero Avatar answered Oct 18 '22 09:10

Arturo Herrero


An alternative: to set the master to track the remote, during your first push execute:

git push -u origin master

The -u will do the same as --set-upstream. After, run git branch -vv to see a list of branches including their tracking branches.

like image 42
Dave Bettin Avatar answered Oct 18 '22 08:10

Dave Bettin


What is your branch.autosetupmerge set to? By default it should have setup the branch tracking when you cloned.

Try setting the upstream for the branch with this to make the branch track the remote.

git branch --set-upstream master origin/master
like image 194
Arrowmaster Avatar answered Oct 18 '22 09:10

Arrowmaster