$ git pull --rebase upstream a_branch_that_we_KNOW_is_there fatal: Couldn't find remote ref a_branch_that_we_KNOW_is_there Unexpected end of command stream
1) the name of your remote repository is "upstream"
2) the branch you are pulling from is called "a_branch_that_we_KNOW_is_there"
There may be many ways to get this kind of error, but I suspect that I am not the only one who will get caught by this time wasting variant.
Reason: The reason you are getting the error is because the branch DOES exist at the correct repository, but you have requested a pull or fetch from the wrong repository. And that branch name does NOT exist in the repo that you have requested a pull or fetch from.
How is that possible?
Cause: You may have accidentally added a remote name that points to the wrong git repository.
You can check the repository that your remote points to this way:
$ git remote show upstream * remote upstream Fetch URL: https://github.com/pkg/pkg-module.git Push URL: https://github.com/pkg/pkg-module.git HEAD branch: master Remote branches: some_other_branch_that_we_do_not_expect tracked master tracked Local ref configured for 'git push': master pushes to master (local out of date)
Or maybe this way:
$ git config --list | grep upstream remote.upstream.url=https://github.com/pkg/pkg-module.git remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*
Either way, check very carefully that the Fetch URL is correct. If you are silly like we are and have several modules in the same package, you may not have noticed the rogue:
git remote add upstream https://github.com/pkg/pkg-module.git
instead of the correct git repository:
git remote add upstream https://github.com/pkg/pkg-modulo.git
Easy to miss something like this, if you ask me.
Solution: remove the name of the remote that points to the wrong repo, and re-add the name back so that it points to the correct git repository. Assuming your remote alias name is "upstream", you can fix that like this:
$ git remote rm upstream $ git remote add upstream https://github.com/pkg/pkg-modulo.git
Now Your pull command should work successfully. But just in case, here is yet another way to check to make sure:
$ git ls-remote | grep a_branch_that_we_KNOW_is_there From https://github.com/pkg/pkg-modulo.git 934a29d142efda2f40efced8a2126c5499162e03 refs/heads/a_branch_that_we_KNOW_is_there
Hope that helps.