Your configuration specifies to merge with the ref

Your configuration specifies to merge with the ref

1. 执行 git pull 命令时,错误提示:

Your configuration specifies to merge with the ref 'refs/heads/task_floor_display' from the remote, but no such ref was fetched.

如上问题(您的配置指定要与来自远端的task_floor_display分支合并,但是没有获取到这样的分支task_floor_display),可能产生原因与解决方案:

1.1 场景:分支名称拼写错误

1.1.1 场景描述

当需要切换子分支时,发现切换命令执行成功后,想拉去新分支的代码时,git pull命令会出现此失败。

1.1.2 产生原因

子分支可能是同事创建的,子分支的命名比较晦涩难记,难免将分支名称记错或者单词被拼写错误,最容易导致此种场景。建议git创建子分支时,名称字符全部小写,词间用下划线隔开,这样可以降低出错概率。

1.1.3 解决方案

由于是将分支名称拼写错误,请仔细检查分支名称每一个字母(尤其注意大小写)和下划线等字符。

为了还原“事故现场”,再演示一遍。

如果分支名称写错,那么就会出现如下的操作场景(一个很好的分支名称错误实例:分支名称的大小写错误,即将小写t误写成大写T酿成的悲剧)。

kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_SteelConcrete)
$ git checkout task_identify_roof_Tie
Branch task_identify_roof_Tie set up to track remote branch task_identify_roof_Tie from origin.
Switched to a new branch 'task_identify_roof_Tie'

kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_identify_roof_Tie)
$ git pull
Your configuration specifies to merge with the ref 'refs/heads/task_identify_roof_Tie'
from the remote, but no such ref was fetched.

kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_identify_roof_Tie)
$ git checkout task_identify_roof_tie
Switched to branch 'task_identify_roof_tie'

kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_identify_roof_tie)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> task_identify_roof_tie


kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_identify_roof_tie)
$ git branch --set-upstream-to=origin/task_identify_roof_tie task_identify_roof_tie
Branch task_identify_roof_tie set up to track remote branch task_identify_roof_tie from origin.

kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_identify_roof_tie)
$ git pull
Already up-to-date.

kaizenly@kaizenly-P1 MINGW64 /f/integration/gjg (task_identify_roof_tie)
$

特别注意:GIT命令不区分大小写,但是GIT命令中使用的分支名称是区分大小写的。

1.2 场景:远程端同名分支已被删除

1.2.1 场景描述

当需要切换子分支时,发现切换命令执行成功后,想拉去新分支的代码时,git pull命令会出现此失败。

1.2.2 产生原因

以前本地拉取过此分支的代码,现在切换分支命令执行成功。但是当想拉去此分支代码时,git发现远端库中此分支已经被人删除,无法准确指定到此分支。

1.2.3 解决方案

重新建个分支,如下命令:

1 ----------------------------------------------------------
2 git checkout integration
3 git pull
4 git branch task_floor_display
5 git push origin task_floor_display
6 git push --set-upstream origin task_floor_display
7 git checkout task_floor_display
8 git pull
9 ----------------------------------------------------------

1.3 场景:其它场景(排除场景1和场景2)

1.3.1 场景描述

当需要切换子分支时,发现切换命令执行成功后,想拉去新分支的代码时,git pull命令会出现此失败。

1.3.2 产生原因

本地git命令操作不规范,或者旧分支有冗余的代码,导致可能会出现此错误。

1.3.3 解决方案

通过clean up命令清理一次。先备份(因为clean up会删除掉)好多余代码,在本地代码source根目录下,执行clean up命令,然后再执行git pull命令。

posted @ 2023-07-30 09:26  kaizenly  阅读(1252)  评论(0编辑  收藏  举报
打赏