Git에서 유효하지 않은 원격 분기 참조를 어떻게 제거합니까?
현재 저장소에는 다음과 같은 출력이 있습니다.
$ git branch -a
* master
remotes/origin/master
remotes/public/master
remotes/public/master분기 목록에서 삭제하고 싶습니다 .
$ git branch -d remotes/public/master
error: branch 'remotes/public/master' not found.
또한의 출력은 다음을 git remote나열하지 않기 때문에 이상합니다 public.
$ git remote show
origin
지점 목록에서 '리모트 / 공개 / 마스터'를 삭제하려면 어떻게해야합니까?
업데이트, 다음 git push명령을 시도했습니다 .
$ git push public :master
fatal: 'public' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
정리가 필요할 수 있습니다.
git gc --prune=now
또는 자두가 필요할 수 있습니다
git remote prune public
치다
<name> 아래의 모든 부실 추적 분기를 삭제합니다. 이러한 부실 분기는 <name>에서 참조하는 원격 저장소에서 이미 제거되었지만 "remotes / <name>"에서 로컬로 계속 사용할 수 있습니다.
--dry-run 옵션을 사용하여 잘라낼 분기를보고하지만 실제로 잘라내지는 않습니다.
그러나 이들은 이전에
git remote rm public
rm
이름이 <name> 인 원격을 제거하십시오. 모든 원격 추적 분기 및 원격에 대한 구성 설정이 제거됩니다.
따라서 구성 파일을 직접 편집했는데 이것이 발생하지 않았거나 권한 문제가있을 수 있습니다.
다시 실행하여 무슨 일이 일어나는지보십시오.
조언 컨텍스트
개정 로그를 살펴보면 내가 더 많은 "올바른"기술을 제안했음을 알 수 있습니다. 어떤 이유로 든 저장소에서 작업하고 싶지 않은 것입니다.
나는 OP가 나무를 일관되지 않은 상태로 남겨 두어 약간 이상하게 행동 git gc하고 남은 잔해물을 고쳐야하는 일을했다고 의심했습니다 .
일반적으로 git branch -rd origin/badbranch 로컬 추적 분기 또는 git push origin :badbranch원격 분기 를 nuking하는 데 충분 하며 일반적 으로 호출 할 필요 가 없습니다.git gc
당신이해야 할 일은
git fetch -p
원격으로 삭제 된 모든 로컬 브랜치를 제거합니다.
git 1.8.5 이상인 경우 자동으로 설정할 수 있습니다.
git config fetch.prune true
또는
git config --global fetch.prune true
git push public :master
이렇게하면 masterKent Fredric이 지적한 원격 지점이 삭제 됩니다.
원격 추적 분기를 나열하려면 :
git branch -r
원격 추적 분기를 삭제하려면 :
git branch -rd public/master
당신이해야 할 일은
$ git branch -rd origin/whatever
그렇게 간단합니다. 여기서 gc를 호출 할 이유가 없습니다.
git gc --prune=now 당신이 원하는 것이 아닙니다.
git remote prune public
또는 git remote prune origin# 원격 소스 인 경우
당신이 원하는 것입니다
심판이 포장되었을 때 받아 들여진 대답은 나를 위해 작동하지 않았습니다. 그러나 이것은 다음을 수행합니다.
$ git remote add public http://anything.com/bogus.git
$ git remote rm public
In my case I was trying to delete entries that were saved in .git/packed-refs. You can edit this plain text file and delete entries from it that git br -D doesn't know how to touch (At least in ver 1.7.9.5).
I found this solution here: https://stackoverflow.com/a/11050880/1695680
git push origin --delete <branch name>
Referenced from: http://www.gitguys.com/topics/adding-and-removing-remote-branches/
I didn't know about git branch -rd, so the way I have solved issues like this for myself is to treat my repo as a remote repo and do a remote delete. git push . :refs/remotes/public/master. If the other ways don't work and you have some weird reference you want to get rid of, this raw way is surefire. It gives you the exact precision to remove (or create!) any kind of reference.
Only slightly related, but still might be helpful in the same situation as we had - we use a network file share for our remote repository. Last week things were working, this week we were getting the error "Remote origin did not advertise Ref for branch refs/heads/master. This Ref may not exist in the remote or may be hidden by permission settings"
But we believed nothing had been done to corrupt things. The NFS does snapshots so I reviewed each "previous version" and saw that three days ago, the size in MB of the repository had gone from 282MB to 33MB, and about 1,403 new files and 300 folders now existed. I queried my co-workers and one had tried to do a push that day - then cancelled it.
I used the NFS "Restore" functionality to restore it to just before that date and now everythings working fine again. I did try the prune previously, didnt seem to help. Maybe the harsher cleanups would have worked.
Hope this might help someone else one day!
Jay
I had a similar problem. None of the answers helped. In my case, I had two removed remote repositories showing up permanently.
My last idea was to remove all references to it by hand.
Let's say the repository is called “Repo”. I did:
find .git -name Repo
So, I deleted the corresponding files and directories from the .git folder (this folder could be found in your Rails app or on your computer https://stackoverflow.com/a/19538763/6638513).
Then I did:
grep Repo -r .git
This found some text files in which I removed the corresponding lines. Now, everything seems to be fine.
Usually, you should leave this job to git.
'Programing' 카테고리의 다른 글
| Razor보기 페이지에서 네임 스페이스를 가져 오려면 어떻게하나요? (0) | 2020.09.30 |
|---|---|
| 파이썬에서 do-while 루프를 에뮬레이트합니까? (0) | 2020.09.30 |
| JavaScript 배열을 선언 할 때“Array ()”와“[]”의 차이점은 무엇입니까? (0) | 2020.09.29 |
| 하나의 클라이언트에서 여러 SSH 개인 키를 사용하는 가장 좋은 방법 (0) | 2020.09.29 |
| Java에서 InputStream을 바이트 배열로 변환 (0) | 2020.09.29 |