329 字
2 分鐘
瀏覽次數
Git fetch/pull Failing? Complete Solution for Case-Sensitive Branch Conflicts
2026-03-31
2026-04-14

Conclusion#

  • Use commands to find case-sensitive conflicts → keep one → delete redundant branches, and you can resolve Git fetch/pull failures.

Applicable Scenarios#

  • Windows / Mac developers encountering Git pull failures
  • Teams using a mix of Linux + Windows
  • Lack of unified branch naming conventions
  • CI/CD suddenly unable to find branches

Step-by-Step Process#

1. Identify Case-Sensitive Conflict Branches#

  • Use git ls-remote to fetch remote branches, convert them to lowercase, and then group and compare.
  • The core idea is to find branches with “different names but identical after converting to lowercase”.
Terminal window
git ls-remote --heads origin |
ForEach-Object { ($_ -split "`t")[1] } |
Group-Object { $_.ToLower() } |
Where-Object { $_.Count -gt 1 } |
Select-Object -ExpandProperty Group

👉 This step is crucial; conflicts cannot be resolved if not identified.

2. Decide Which Branch to Keep#

  • Usually standardize to lowercase (e.g., feature/login)
  • Or decide according to team conventions 👉 Git is case-insensitive on Windows, so only one can be kept.

3. Delete Redundant Branches#

  • Delete conflicting remote branches
Terminal window
git push origin --delete Feature/Login
  • Remember to synchronize local after deletion
Terminal window
git fetch --prune

👉 prune is very important, otherwise old data will remain locally.

Additional Notes#

  • Windows / Mac default to case-insensitive file systems, while Linux is case-sensitive → source of conflict
  • It is not recommended to use the reftable solution, as tool support is still unstable.
  • If CI/CD is tied to the wrong branch, confirm the pipeline before deleting.

Command / Example Summary#

Click to expand
Terminal window
# 找出大小寫衝突
git ls-remote --heads origin |
ForEach-Object { ($_ -split "`t")[1] } |
Group-Object { $_.ToLower() } |
Where-Object { $_.Count -gt 1 } |
Select-Object -ExpandProperty Group
Terminal window
# 自訂 function
function Find-GitCaseConflict {
git ls-remote --heads origin |
ForEach-Object { ($_ -split "`t")[1] } |
Group-Object { $_.ToLower() } |
Where-Object { $_.Count -gt 1 } |
Select-Object -ExpandProperty Group
}
Terminal window
# 刪除遠端分支
git push origin --delete Feature/Login
# 清理本地
git fetch --prune

Wrap-up#

  • Inconsistent Git branch casing is a ticking time bomb.
  • It is recommended to standardize naming (all lowercase) from the beginning to avoid many pitfalls later.

Git fetch/pull Failing? Complete Solution for Case-Sensitive Branch Conflicts
https://joyceowo.github.io/posts/en/334a78ea09fa80a889fbf092a1576c5e/
作者
JoyceOwO
發佈於
2026-03-31
許可協議
CC BY-NC-SA 4.0