首页 > 解决方案 > 如何使用 git bash 切换到另一个用户的分支

问题描述

我正在开发一个 GitHub 项目,我正在尝试从 master 切换到另一个用户的分支。他们的分支领先于 master 并且有多个更改。无论我尝试什么,我都无法切换到他们的分支并获得他们的更改。

我尝试了许多 gitbash 命令,包括 checkout、pull、clone、fetch。

git clone link
git checkout branchName
git fetch branchName
git fetch

我希望“git checkout branchName”切换到其他用户的分支,但它只是切换到具有相同名称的全新本地分支。“git fetch branchName”只是返回一个错误。

我已经使用 git 多年了,我觉得自己像个白痴,我无法弄清楚这一点。我也无法在网上的任何地方找到解决方案。

标签: gitrepositorygit-bash

解决方案


git checkout <other_users_remote>/branchNamegit checkout -b branchName <other_users_remote>/branchName创建一个跟踪分支

您是否添加了其他人的遥控器?git remote -v


推荐阅读