I find git docs very cryptic regarding this issue. I want to do a simple thing, but it seems doing it is not simple at all.
I have the following situation:
$ git remote -v
origin git://192.168.0.49/mnt/repos
stick /mnt/titanium/podaci/repos
I can use git pull to fetch and merge from origin, and that works fine:
$ git pull
Already up-to-date.
I can pull from stick like this:
$ git pull stick master
Already up-to-date.
However, when I pull from stick without the master part, I get this message:
$ git pull stick
From /mnt/titanium/podaci/repos
* [new branch] su2009 -> stick/su2009
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.
If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:
branch.master.remote = <nickname>
branch.master.merge = <remote-ref>
remote.<nickname>.url = <url>
remote.<nickname>.fetch = <refspec>
See git-config(1) for details.
Some things confuse me here. What does “your configuration file” mean here? Which file should I edit, and what exactly should I type in? What’s nickname in this case?
I would expect that what I’m trying to accomplish is very common, but I haven’t been able to find a straight-to-the-point answer with an example.
Your repo’s configuration file, found at
.git/configat the root of your repo. (There’s also a per-user global config file at~/.gitconfig, but you don’t want to put repo-specific settings there.)You can use the
git configprogram to write configuration information, instead of entering it manually. However, if you want to do it manually, just open up.git/config— the syntax is fairly straightforward.Nickname, in this case, is the name of the remote — so “stick”. You don’t have to worry about the
remote.*options, as those have already been set up, but you do need to set thebranch.*options. These options tell Git what to merge when doing agit pullfrom stick.Say you want to merge in master from stick when doing a
git pullfrom stick. You can do so like this:So now, when you do a
git pullwithout any remote or refspec info, it’ll fetch all the branches from stick, and merge in stick’s master branch. Note that origin will not be the default remote anymore; to merge in origin’s master branch, you’ll have to usegit pull origin master.If you don’t want to change the default remote to stick, you’ll have to continue using
git pull stick master.