leonbloy leonbloy - 11 months ago 138
Git Question

Git: which is the default configured remote for branch?

I have a remote bare repository

. I work only in the
The last sentence of this error message below makes me wonder: How do I find out which is the "default configured remote for your current branch"? And how do I set it?

[myserver]~/progs $ git remote -v
hub ~/sitehub/progs.git/ (fetch)
hub ~/sitehub/progs.git/ (push)
[myserver]~/progs $ git branch -r
[myserver]~/progs $ git remote -v
hub ~/sitehub/progs.git (fetch)
hub ~/sitehub/progs.git (push)
[myserver]~/progs $ cat .git/HEAD
ref: refs/heads/master
[myserver]~/progs $ git pull hub
You asked to pull from the remote 'hub', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

Answer Source

Track the remote branch

You can specify the default remote repository for pushing and pulling using git-branch’s track option. You’d normally do this by specifying the --track option when creating your local master branch, but as it already exists we’ll just update the config manually like so:

Edit your .git/config

[branch "master"]
  remote = origin
  merge = refs/heads/master

Now you can simply git push and git pull.