👉 기본 환경
- Git Bash
⌨️ 코드
1
2
3
4
5
6
7
|
# git push origin --delete feat/3
git push remote_name --delete branch_name
# 동일한 기능
# git push origin :feat/3
git push remote_name :branch_name
|
🖨️오류
1
2
|
error: unable to delete feat/3: remote ref does not exist
|
📡 원인
원격 서버에 삭제하려는 branch가 존재하지 않음
🚨 전체 branch 조회 시, 삭제하고자하는 branch 조회
1
2
|
git branch -a
|
원격 branch만 조회할 경우,
1
2
|
git branch -r
|
⭐ 로컬에 기록되어있는 remote 서버 branch 정보와 실제 remote 서버 branch 정보가 일치하지 않음
로컬 pc의 remote branch 정보를 동기화 된지 오래된 경우, 문제 발생
📰 해결 방법
1
2
|
git fetch -p origin
|
fetch 명령어를 통해서 실제 remote 서버의 branch 정보를 가져와 로컬 pc에 갱신
-p: 가지치기(prune)
📚 참고 자료
[Git] 오류 해결 error: unable to delete '브랜치명': remote ref does not exist
gitlab으로 협업을 하다 보니까 git branch가 많이 쌓이게 되어 정리를 하였다.로컬 브랜치는 알아서 개인적으로 하면 되지만 remote는 별도로 관리하지 않으면 방치가 될 수 있다.git remote branch를 정리
velog.io
[Git] 원격 저장소 연결 및 끊기 원격브랜치 갱신, 조회, 삭제
협업을 하다보면 로컬 저장소(local repository)와 구분되게 원격 저장소(remote repository)를 연결해야 할 때가 있다. 현재 연결되어 있는 원격 저장소(remote repository) 확인 $ git remote -v 원격 저장소 연결 $
hu-coding.tistory.com
브랜치를 로컬과 원격에서 모두 삭제하는 법
깃 브랜치를 삭제하는 법은 간단하다. 로컬과 원격 두군데에서 모두 브랜치를 삭제하는 법을 알아보자. 간단히 요약하자면 아래와 같다. // 로컬에서 브랜치 삭제하기 명령어 git branch -d localBranch
www.freecodecamp.org
'DevOps > Git' 카테고리의 다른 글
[해결 방법] bash: syntax error near unexpected token '(' (0) | 2023.10.16 |
---|---|
[Git Bash] Github 기존 Repository와 Local PC 연결 (0) | 2023.04.02 |
[Git Bash] 저장소의 폴더 및 파일 삭제 (1) | 2023.01.22 |
[해결 방법] fatal: refusing to merge unrelated histories (0) | 2023.01.22 |
Git 설치 및 초기 설정 (0) | 2023.01.22 |