2

I have two remotes configured for my working copy. One I use regularly - it is called origin. Another I use for occasional backup - it is called assembla. Now when I pull from assembla, I always get this:

$ git pull assembla
You asked to pull from the remote 'assembla', 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.

This is easily resolved like this:

$ git pull assembla master

but I don't want to add master to the command every time I do that.

Is there any way to pre-configure "default" local branch for each remote, to make the command shorter?

Just in case: I don't want to change the default configured remote for this branch, as proposed here.

Community
  • 1
  • 1
  • Possible duplicate of [How do you get git to always pull from a specific branch?](http://stackoverflow.com/questions/658885/how-do-you-get-git-to-always-pull-from-a-specific-branch) – J. Titus Dec 06 '16 at 13:32
  • It is not a duplicate of the mentioned question, because the later suggests changing the default configured remote, which I do not want to do. – Dmitry Savvateev Dec 06 '16 at 14:05

2 Answers2

0

Assuming you're in the addsembla branch, navigate to your config file. It should be in /<project>/.git/config. Open up an editor (e.g. nano or Vim) and add the following lines:

[branch "master"]
    remote = assembla
Jake Henningsgaard
  • 704
  • 1
  • 6
  • 16
  • 1
    This will change the default remote, so that `git pull` will pull from assembla. This is not what I want. – Dmitry Savvateev Dec 06 '16 at 14:29
  • Yeah you're right, I misunderstood. In that case, I would probably take @Melebius approach. Depending on where your hosting the remote repos, you may be able to set a default branch there. Not sure if that would work or not. – Jake Henningsgaard Dec 06 '16 at 14:52
0

You can set up an alias command.

git config alias.pullassembla 'pull assembla master'

Then run it using:

git pullassembla

Of course, you can use another name for the alias.

Melebius
  • 6,183
  • 4
  • 39
  • 52