4
[console]: git remote -v
origin git@testServer.com:myProj/myProj.git(fetch)
origin git@testServer.com:myProj/myProj.git(push)

[console]: git branch -a
*myBranch
development
remotes/origin/myBranch
remotes/origin/development

[console]: git pull origin/myBranch myBranch
fatal: 'origin/myBranch' does not appear to be a git repository
fatal: Could not read from remote repository

I originally made this branch and have been pushing to it for a while. Although yesterday I did rebase from another branch into my branch so maybe that messed something up?

Grammin
  • 11,808
  • 22
  • 80
  • 138

2 Answers2

13

You have the syntax wrong: it's git pull [ remote [ branch-name ] ], not git pull remote/branch-name branch-name. In this case you would need git pull origin myBranch.

That said, I recommend not using git pull at all, at least not until you are very familiar with Git. The reason is that git pull does two things, and the second thing it does is run git merge, which:

  • can fail to happen automatically, stop in the middle, and need help from you;
  • produces "foxtrot merges", which are sort of backwards, whenever it makes a real merge;
  • is usually better done as git rebase anyway.

The first half of git pull is git fetch, so you can just run git fetch and then, after it succeeds, run either git merge or git rebase as desired. Both of these commands take much more sensible arguments than git pull.

With git fetch, you name the remote to fetch from, e.g., git fetch origin (or just let git fetch figure it out: git fetch with no arguments will generally figure out to use origin automatically).

With both git merge and git rebase, you name the origin/myBranch remote-tracking branch, or just let Git figure it out, again.

All that also said, git pull will usually figure all of these out on its own as well. In particular if git merge or git rebase can figure out to use origin/myBranch, git pull can figure out to use origin and origin/myBranch for its two steps.

Community
  • 1
  • 1
torek
  • 448,244
  • 59
  • 642
  • 775
6

The correct syntax is git pull origin myBranch The first argument of the command should be the name of the remote, as suggested by the error fatal: 'origin/myBranch' does not appear to be a git repository

Flows
  • 3,675
  • 3
  • 28
  • 52
  • I just found out today that git pull origin branch isn't working as I'd expect... after I do it, I always check that my sha's are the same with git branch -a -vv. They weren't though... so I checked out my local version of that remote branch and did a git pull ... it updated.. then i went back to the branch I had been working on and did a git pull origin branch again and THIS time there were updates... so its almost like git pull origin branch was ONLY looking at my local branch copy... wth? – carinlynchin Nov 16 '18 at 16:07