Programing

Git은 원격 지점을 삭제할 때 원격 참조가 존재하지 않는다고 말합니다.

lottogame 2020. 8. 12. 22:06
반응형

Git은 원격 지점을 삭제할 때 원격 참조가 존재하지 않는다고 말합니다.


나는 달렸다 git branch -a

* master
  remotes/origin/test
  remotes/origin/master

원격 지점을 삭제하고 싶습니다

난 노력 했어

git push origin --delete remotes/origin/test

나는 얻었다

오류 : 'remotes / origin / test'를 삭제할 수 없습니다 : 원격 참조가 존재하지 않습니다.

어떻게 존재하지 않습니까?

나는했고 git branch -a그것이 나열된 것을 보았다.

내가 놓친 것이 있습니까?


이 명령 git branch -a로컬 저장소에있는 원격 분기를 표시 합니다 . 다소 혼란 스러울 수 있지만 이해하려면 원격 브랜치와 원격 저장소에 존재하는 브랜치 사이에 차이가 있음을 이해해야합니다. 원격 분기는 원격 저장소의 분기에 매핑 되는 로컬 분기입니다. 따라서 원격 분기 집합은 원격 저장소의 상태를 나타냅니다.

원격 분기 목록을 업데이트하는 일반적인 방법은 git fetch. 이렇게하면 원격에서 업데이트 된 분기 목록을 자동으로 가져오고 로컬 저장소에 원격 분기를 설정하며 누락 될 수있는 커밋 객체도 가져옵니다.

그러나 기본적 git fetch으로은 원격 분기에 더 이상 대응 분기가없는 원격 분기를 제거하지 않습니다. 그렇게하기 위해서는, 당신은 명시 적으로 할 필요가 치기 원격 지점의 목록을 :

git fetch --prune

그러면 원격지에 더 이상 존재하지 않는 원격 분기가 자동으로 제거됩니다. 나중에 git branch -r원격지에 실제로 존재하는 분기의 업데이트 된 목록이 표시됩니다 git push.

즉,를 사용 git push --delete하려면 원격 저장소에서 브랜치의 이름을 지정해야합니다. 원격 지점의 이름이 아닙니다. 따라서 분기 test(원격 분기로 origin/test표시됨) 를 삭제 하려면 git push origin --delete test.


의 의미 는 원격 서버에서 remotes/origin/test호출 test분기가 있다는 것 origin입니다. 따라서 명령은

git push origin --delete test

오리진에서 분기를 삭제하는 바로 가기가 있습니다.

git push origin :<branch_name>

하는 것과 같은 git push origin --delete <branch_name>


git push origin --delete yourBranch


  1. 원격 지점 목록 가져 오기
git fetch # synchronize with the server
git branch --remote # list remote branches
  1. 원격 분기 목록을 가져와야합니다.
origin/HEAD -> origin/master
origin/develop
origin/master
origin/deleteme
  1. 이제 분기를 삭제할 수 있습니다.
git push origin --delete deleteme

원격 브랜치가 remotes / origin / test 인 경우 두 가지 방법을 사용할 수 있습니다.

git push origin --delete test

git branch -D -r origin/test

원점에서 'master'이외의 분기를 삭제하는 편리한 한 줄 :

git branch --remotes | grep -v 'origin/master' | sed "s/origin\///" | xargs -i{foo} git push origin --delete {foo}

실행하기 전에 실행의 의미를 이해해야합니다!


git branch -a will list the branches in your local and not the branches in your remote.

And the error error: unable to delete 'remotes/origin/test': remote ref does not exist means you don't have a branch in that name in your remote but the branch exists in your local.


For me this worked $ ▶ git branch -D -r origin/mybranch

Details

$ ▶ git branch -a | grep mybranch remotes/origin/mybranch

$ ▶ git branch -r | grep mybranch origin/mybranch

$ ▶ git branch develop * feature/pre-deployment

$ ▶ git push origin --delete mybranch error: unable to delete 'mybranch': remote ref does not exist error: failed to push some refs to 'git@10.102.100.38:config/myrepo.git'

$ ▶ git branch -D -r origin/mybranch Deleted remote branch origin/mybranch (was 62c7421).

$ ▶ git branch -a | grep mybranch

$ ▶ git branch -r | grep mybranch


git push origin --delete origin/test 

should work as well

참고URL : https://stackoverflow.com/questions/35941566/git-says-remote-ref-does-not-exist-when-i-delete-remote-branch

반응형