Visual Studio 如何使用git从特定分支拉取更新

rqenqsqc  于 2023-02-13  发布在  Git
关注(0)|答案(2)|浏览(485)

我不是git方面的Maven。
我编写了以下代码:

PS C:\Users\xxx\Desktop\Python Yamed> git branch
  explore
* master

我想从branchexplore中提取更新
我尝试了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=<remote>/<branch> master

我也试过

git pull origin explore

但我得到一个错误如下:

PS C:\Users\xxx\Desktop\Python Yamed> git pull origin explore
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

一些可能有用的信息:
PS C:\用户\xxxx\桌面\Python Yamed〉git远程-v

YakeeyData      https://github.com/yakeey/yk-estimate.git (fetch)
YakeeyData      https://github.com/yakeey/yk-estimate.git (push)
Yakeey_Data     https://github.com/yakeey/yk-estimate.git (fetch)
Yakeey_Data     https://github.com/yakeey/yk-estimate.git (push)
jogvjijk

jogvjijk1#

由于OP的问题被贴上了“Visual Studio”的标签,除了Fares的答案之外,还值得注意
https://stackoverflow.com/a/74000282/15569110
Visual Studio 2022不允许在界面中右键单击 remote branches 时从名为origin以外的远程分支提取非本地分支。
然而,如果你想获取/推送带有本地分支的refs到一个与origin不同的远程分支,那么你必须先设置你的远程跟踪分支。

> git fetch YakeeyData explore
> git branch -u YakeeyData/explore explore

这将确保explore正在跟踪YakeeyData/explore。然后,在Visual Studio 2002中,您可以右键单击**本地分支 * explore以从远程YakeeyData获取/向远程YakeeyData推送。

sz81bmfz

sz81bmfz2#

使用git,你可以通过git remote add(从“Git Basics - Working with Remotes“)添加任意数量的上游repo地址。
在您的示例中,没有名为origin的上游回购,它似乎被称为YakeeyData
因此,您只需要执行git pull YakeeyData explore
在下面,此命令将生成以下两个命令

git fetch YakeeyData explore && git merge explore

相关问题