17

I am not using github. We have git setup on our machine.

I created a branch from master called experiment. However when I am trying to do git pull I am getting following message.

> git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.experiment.merge' in
your configuration file does not tell me either.    Please
specify 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.

Here is result of git remote show origin

> git remote show origin
* remote origin
  Fetch URL: ssh://git.domain.com/var/git/app.git
  Push  URL: ssh://git.domain.com/var/git/app.git
  HEAD branch: master
  Remote branches:

    experiment      tracked
    master          tracked
  Local branches configured for 'git pull':
    master     merges with remote master
  Local refs configured for 'git push':
    experiment pushes to experiment (local out of date)
    master     pushes to master     (up to date)

As I read the message above experiment is mapped to origin/experiment. And my local repository knows that it is out of date. Then why I am not able to do git pull?

This is how I created this branch

git co -b experiment origin/experiment

Nick Vanderbilt
  • 36,724
  • 29
  • 83
  • 106

3 Answers3

25

Pull:

git pull origin experiment

Push:

git push origin experiment
dav_i
  • 27,509
  • 17
  • 104
  • 136
Stewie Griffin
  • 9,257
  • 22
  • 70
  • 97
  • Thanks. Does anyone what do I need to so that git pull and git push alone would do the work. – Nick Vanderbilt Mar 12 '10 at 15:34
  • 1
    you can create GIT alias. For instance, if you are going to use only that experiment branch, you could write a command pull e or smth like this, which would do the same git pull origin experiment. Read here about alias: http://git.wiki.kernel.org/index.php/Aliases – Stewie Griffin Mar 12 '10 at 15:38
  • but why does `git pull` work for some branches but not others? Normally `git pull` will pull the currently checked out branch from origin but in some cases it doesn't and you get the error message described by OP. I don't understand why this discrepancy occurs. – geoidesic Jun 08 '17 at 11:28
2

Check answers for this question for informations and change "master" to "experiment" for your example

Community
  • 1
  • 1
MBO
  • 30,379
  • 5
  • 50
  • 52
0

I was facing this issue in my eclipse github plugin .

This might be happening because of some conflict files present in your repository .And you was still trying to check in files . So After that what happen , it will check in your local repository not in master repository . So u was not able to pull or check in anythings in master(head) repository .

I have one solution might be useful , it works for me maximum times. Just follow these steps :- 1)right click on conflict file 2)click on replace with -> head revision 3)wait for some times (keep patient , it will take time ) 4)repeat all previous steps for all conflict files

Vijay
  • 4,694
  • 1
  • 30
  • 38