git: Fix pull failing when tracking remote with different branch name (#41768)

Closes #31430

Release Notes:

- Fixed git pull failing when tracking remote with different branch name

Here's a before/after comparison when `dev` branch has upstream set to
`origin/main`:


https://github.com/user-attachments/assets/3a47e736-c7b7-4634-8cd1-aca7300c3a73
0b1d3d78a4Mayank Verma committed on 11/6/2025, 5:18:08 AM· committed by GitHubparent930b489
5 files changedLine totals unavailable