首页 > 解决方案 > Cannot pull with git

问题描述

We have a branch in our git repo called feature/TestBapi.

I created a new remote connection to repository MyRepoA : git remote add repo-A-branch ../MyRepoA

When i do git pull repo-A-branch feature/TestBapi --allow-unrelated-histories i get :

fatal: Couldn't find remote ref feature/TestBapi
fatal: The remote end hung up unexpectedly

In my git config, i have :

branch.feature/TestBapi.remote=origin
branch.feature/TestBapi.merge=refs/heads/feature/TestBapi

To verify the existence of my branch, i did : git checkout --track origin/feature/TestBapi. I get : fatal: A branch named 'feature/TestBapi' already exists.

I am stumped here. Any ideas?

标签: gitmergebranchpull

解决方案


When you say

git pull repo-A-branch feature/TestBapi --allow-unrelated-histories

that means "on repo-A-branch (which you've mapped to ../myRepoA), find the branch named feature/TestBapi; fetch it; and merge the result into my current branch.

As pointed out in multiple ways in the comments, the branch does not exist in ../myRepoA.

When this is pointed out, you reply that the branch exists in the local repo, and/or that it exists at origin. Which is fine, but it doesn't change the fact that it doesn't exist in the repo where you're telling git to look for it.

Perhaps you need to take a step back and review why you're trying to run this command. What are you expecting it to accomplish?


推荐阅读