gpt4 book ai didi

git - 远程分支没有出现在 "git branch -r"

转载 作者:IT王子 更新时间:2023-10-29 01:21:45 24 4
gpt4 key购买 nike

我一直在推送到一个远程 Bitbucket 存储库,最近一位同事将他创建的一个新分支推送到了同一个存储库。

我正在尝试获取他上传的更改。

 $ git branch -a
* master
localbranch1
localbranch2
remotes/origin/master

$ git branch -r origin/master

在 Bitbucket 的网络用户界面中,我可以看到他创建的分支。我该怎么做?

下次尝试:

$ git fetch bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD

如果他创建的分支名为 new_branch_b,我应该期待看到以下内容吗?

$ git branch -r
origin/master
origin/new_branch_b

第三次尝试:

$ git remote update
Fetching bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD

$ git branch -r
origin/master

第四次尝试:

[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git

我调用了远程 bitbucket 而不是 origin(至少我记得是这样;我刚才设置了它)

第五次尝试:

我根据 kan's answer 更新了 Bitbucket 远程配置:

$ git config -e

[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/bitbucket/*

对于大多数人来说,它会被称为起源:

[remote "origin"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*

之后,

$ git remote update

Fetching bitbucket
Password for 'https://user@bitbucket.org':
remote: Counting objects: 48, done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 35 (delta 21), reused 0 (delta 0)
Unpacking objects: 100% (35/35), done.
From https://bitbucket.org/user/repo
* [new branch] branch_name1 -> origin/branch_name1
* [new branch] branch_name2 -> origin/branch_name2

....等等。

我认为 git fetch origin 也适用于 git remote update

最佳答案

如果您还没有更新您的 Remote :

$ git remote update
$ git branch -r

关于git - 远程分支没有出现在 "git branch -r",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12319968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com