IT박스

“git branch -r”에 원격 브랜치가 나타나지 않음

itboxs 2020. 7. 9. 19:33
반응형

“git branch -r”에 원격 브랜치가 나타나지 않음


나는 원격 비트 버킷 리포지토리로 밀고 왔으며 최근에 동료가 그가 만든 새로운 지사를 동일한 리포지토리로 푸시했습니다.

그가 업로드 한 변경 사항을 가져 오려고합니다.

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

$ git branch -r
origin / 마스터

bitbucket의 웹 UI에서 그가 만든 지점을 볼 수 있습니다. 모든 도움 / 조언 / 방향이 가장 높이 평가됩니다. 감사.

추가 정보 만 있으면됩니다.

편집 1

$ 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

편집 2

$ 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

편집 3

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

나는 원점이 아닌 원격 비트 버킷을 호출했습니다 (적어도 그것은 내가 기억하는 것입니다, 나는 얼마 전에 설정했습니다)

편집 4

칸의 답변에 따라 비트 버킷 원격 구성을 업데이트했습니다.

$ 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

.... 등등.

I think git fetch origin would also work for git remote update

Thanks to everyone who helped me with this problem.


The remote section specifies also fetch rules. You could add something like into it:

fetch = +refs/heads/*:refs/remotes/origin/*

to fetch all branches from the remote. (or replace origin by bitbucket).

Please read about it here: https://git-scm.com/book/en/v2/Git-Internals-The-Refspec


Update your remote if you still haven't done so:

$ git remote update
$ git branch -r

If you clone with --depth parameter, it sets .git/config not to fetch all branches, but only master.

You can simple omit the parameter or update config file from

fetch = +refs/heads/master:refs/remotes/origin/master

to

fetch = +refs/heads/*:refs/remotes/origin/*

I had the same issue. Seems the easiest solution is to just remove the remote, re-add it, and fetch.


Unfortunately git branch -a and git branch -r do NOT show you all remote branches, if you haven't executed a "git fetch". git remote show origin works consistently all the time. Also git show-ref shows all references in the git repo. However it works just like git branch command

참고URL : https://stackoverflow.com/questions/12319968/remote-branch-not-showing-up-in-git-branch-r

반응형