Programming

git fetch는 모든 브랜치를 가져 오지 않습니다.

procodes 2020. 6. 4. 21:03
반응형

git fetch는 모든 브랜치를 가져 오지 않습니다.


리포지토리를 복제 한 후 다른 누군가가 새 브랜치를 만들었습니다.이 브랜치는 작업을 시작하고 싶습니다. 나는 매뉴얼을 읽었고, 쉽게 죽는 것처럼 보인다. 이상하게도 작동하지 않으며 내가 찾은 모든 게시물은 내가 옳은 일을하고 있다고 제안합니다. 나는 몹시 때리는에 자신을 복종거야 그래서, 때문에이 있어야 이와 분명히 뭔가 잘못 될 :

올바른 조치는

git fetch
git branch -a
* master
  remotes/origin/HEAD --> origin/master
  remotes/origin/master
git checkout -b dev-gml origin/dev-gml

이 시점에서 어떤 이유로 git fetchdev-gml 원격 지점을 볼 수없는 문제가 있습니다. 왜 안돼? 저장소를 새로 복제하면 거기에 있으므로 원격 지점이 존재합니다.

$ mkdir ../gitest
$ cd ../gitest
$ git clone https://github.com/example/proj.git
Cloning into proj...
remote: Counting objects: 1155, done.
remote: Compressing objects: 100% (383/383), done.
remote: Total 1155 (delta 741), reused 1155 (delta 741)
Receiving objects: 100% (1155/1155), 477.22 KiB | 877 KiB/s, done.
Resolving deltas: 100% (741/741), done.
$ cd projdir
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev-gml
  remotes/origin/master

내가 시도했습니다 git update, git pull, git fetch --all, git pretty-please모든 가능한 순열의 ...


remote.origin.fetch설정을 확인할 때 문제를 볼 수 있습니다
(로 시작하는 $줄은 입력 한 명령이있는 bash 프롬프트입니다. 다른 줄은 결과 출력입니다)

$ git config --get remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master

보시다시피, 제 경우에는 리모콘이 마스터 브랜치를 구체적으로 가져 오도록 설정되었습니다. 결과를 확인하는 두 번째 명령을 포함하여 아래에서 수정했습니다.

$ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
$ git config --get remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*

와일드 카드 *는 물론 해당 경로 아래의 모든 것을 의미합니다.

불행히도 나는 이미 파고 들었고 시행 착오로 답을 찾은 후에이 의견보았습니다 .


나는 오늘 레포 에서이 문제를 겪었다.

+refs/heads/*:refs/remotes/origin/*최고의 솔루션에 따라 문제 가되지 않았습니다 .

가져올 원격 브랜치가 있지만 증상은 단순히 그랬 git fetch origin거나 git fetch아무것도하지 않는 것 같습니다.

많은 것을 시도한 후 원점을 제거하고 다시 만들었습니다. 그것은 그것을 고친 것 같습니다. 이유를 모릅니다.

다음으로 제거 : git remote rm origin

다음을 사용하여 다시 작성하십시오. git remote add origin <git uri>


(신규) 원격 지점을 로컬 지점으로 추적하려면

git checkout -b <local branch> <remote>/<remote branch>

또는 (때로는 추가없이 작동하지 않는 경우 remotes/) :

git checkout -b <local branch> remotes/<remote>/<remote branch>

편집 :git remote update 또는 을 실행해야합니다 git remote update <remote>. 그런 다음 git branch -r원격 분기를 나열하기 위해 실행할 수 있습니다 .

유용한 git cheatsheets


보다 구체적으로 추적 지점을 만듭니다. 이제 원격 지점을 추적하고 있습니다.

git branch --track branch remote-branch
git branch --track exp remotes/origin/experimental

그 후 당신은 할 수 있습니다

git branch   # to see the remote tracking branch "exp" created .

그런 다음 해당 지점에서 작업하려면

git checkout branchname
git checkout exp

After you have made changes to the branch. You can git fetch and git merge with your remote tracking branch to merge your changes and push to the remote branch as below.

git fetch origin
git merge origin/experimental  
git push origin/experimental

Hope it helps and gives you an idea, how this works.


write it from the terminal

git fetch --prune.

it works fine.


This could be due to a face palm moment: if you switch between several clones it is easy to find yourself in the wrong source tree trying to pull a non-existent branch. It is easier when the clones have similar names, or the repos are distinct clones for the same project from each of multiple contributors. A new git clone would obviously seem to solve that "problem" when the real problem is losing focus or working context or both.


I had to go into my GitExtensions Remote Repositories as nothing here seemed to be working. There I saw that 2 branches had no remote repository configured. after adjusting it looks as followsenter image description here

Notice branch noExternal3 still shows as not having a remote repository. Not sure what combo of bash commands would have found or adjusted that.


We had the same problem and you have to use

git fetch

git push origin branch_name

git branch -r

Hope this help someone facing the same problem

참고URL : https://stackoverflow.com/questions/11623862/git-fetch-doesnt-fetch-all-branches

반응형