首页 > 解决方案 > git 命令在 Windows 命令行上工作,但在 Git Bash 终端中不工作

问题描述

我正在使用 Windows cmd 上的 git 命令处理远程存储库,它运行良好,但是在 git bash 终端中使用 git 命令时出现错误:

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

如何为 git bash 终端修复它?

标签: windowsgitcmdgit-bash

解决方案


首先,在您的 git bash 会话中检查以下输出:

git branch -avv
git status

确保您所在分支的名称与远程分支的名称匹配,特别是考虑大小写(大写/小写),以防它在 CMD 会话中不敏感,而在 bash 会话中敏感。
请参阅此示例

git checkout --track origin/branch如果分支列表显示本地分支未链接到远程跟踪分支,那么,正如我在“[和之间的区别git checkout -b branch origin/branch][2]”中记录的那样:

git branch -u origin/branch branch

推荐阅读