programing

git push: refs/heads/my/subbranch가 존재하므로 만들 수 없습니다.

muds 2023. 8. 29. 21:01
반응형

git push: refs/heads/my/subbranch가 존재하므로 만들 수 없습니다.

서버의 저장소에 summe 하위 폴더를 만들 수 없습니까?

내가 한다면,

git push origin dev/master 

찾을 수 있는 모든 것

하지만 내가 한다면,

git push origin dev/sub/master

나는 이것을 받았습니다:

error: 'refs/heads/dev/sub' exists; cannot create 'refs/heads/dev/sub/master'

는 나는확니다습했인으로 했습니다.git branch -rSSH를 사용하면 dev/sub 폴더가 이미 생성되지 않았습니다.

뭐가 잘못됐나요?

존재하는 폴더가 아니라 분기입니다. (참고 자료가 "포장"되고 디렉터리 내의 파일로 존재하지 않게 됨에 따라 폴더/디렉토리가 어딘가에 관련되어 있을 수도 있습니다.)

  • 분기 If 기b존재함, 이름이 지정된 분기 없음b/anything만들 수 있습니다.
  • 분기가 지가면, 만분가기입니다.dev/b 존한다재,dev/b/c만들 수 없습니다.

이것은 약간의 내부 제한입니다.이경 격원origin이름이 지정된 분기가 있습니다.dev/sub(갖고 있든 없든 중요한 것은 리모컨에 가지고 있느냐입니다.)에 만들기 위해,origindev/sub/master 먼저이지분삭합제니다야라는 .dev/suborigin:

git push origin :dev/sub

물론 이 분기를 삭제하면 해당 분기에서 중요한 항목이 삭제될 수 있으므로, 작업 내용을 숙지해야 합니다.일반적으로, 당신은 당신이 것을 원할 것입니다.git fetch origin먼저, 그들의 모습을 포착하기.dev/sub당신과 마찬가지로origin/dev/sub그런 다음 다음 다음과 같은 로컬 분기를 만들 수 있습니다.dev/renamed-sub커밋을 , 동한커을가며키리, 생성을 합니다.dev/renamed-sub원서원 합니다.dev/sub에 '으으으으으으으으으으으으으으으으으으으dev/sub/master원격으로.)


한 경우("(으로 표시되는 시스템)origin on 이름을 변경할 수 .dev/subbranch. (으로 볼 때, 자동 것 . 이 ". (아래 의견을 바탕으로 볼 때, 자동 배포 스크립트도 손상된 것 같습니다. 이 스크립트는 푸시되는 모든 것이 아니라 "배포 가능한" 분기만 배포하도록 수정해야 합니다.하지만 저는 여기서 추측하고 있습니다.)

제 레포에 체크아웃하지도 않은 기존 원격 지점에 대한 정보가 있어서 가져올 수조차 없는 상태였습니다.저는 다음의 조합(덕분에 @torek)을 실행하여 해결했습니다.

  • git branch -r
  • git ls-remote remote branchs
  • git fetch --prune origin원격 지점의 로컬 복사본 업데이트(실제로 도움이 되지 않음)
  • git remote prune origin제거된 원격 분기에 대한 정보 제거( 작업을 수행함)

나를 위해 -->

오류 =

fatal: cannot lock ref 'refs/heads/release/wl/2.3': 'refs/heads/release/wl' 
exists; cannot create 'refs/heads/release/wl/2.3'

솔루션 =

$~ git update-ref -d refs/heads/release/wl
$~ git checkout release/wl/2.3

삭제할 원격 보고서에 대한 참조가 없었기 때문에 현재 수락된 답변은 도움이 되지 않았습니다. 순전히 현지에서 작성한 것입니다!따라서 이러한 상황에 처하면 다음과 같이 처리할 수 있습니다.

이것이 제가 직면한 문제입니다.

$ git fetch origin
error: cannot lock ref 'refs/remotes/origin/fix/sub-branch': 
'refs/remotes/origin/fix' exists; cannot create 
'refs/remotes/origin/fix/sub-branch'
From <repo URL>
 ! [new branch]      fix/sub-branch          -> origin/fix/sub-branch
 (unable to update local ref)

저는 수락된 답변의 제안을 시도했지만 다음과 같이 받았습니다.

$ git push origin :fix
error: unable to delete 'fix': remote ref does not exist
error: failed to push some refs to <repo URL>

그래서 심판은 존재하지도 않았습니다.origin분명히 제 지역 레포의 어딘가에서 어슬렁거리고 있었습니다.그래서 뛰었습니다.$ git remote show me다음과 같은 결과를 낳았습니다.

Remote branches:
...
refs/remotes/origin/fix             stale (use 'git remote prune' to remove)
...

그리고 나서 해결책을 명확하게 했습니다.

$ git remote prune origin
Pruning origin
URL: <redacted>
 * [pruned] origin/fix

이를 통해 문제가 사라졌습니다.

$ git fetch origin
remote: Counting objects: 5, done.
remote: Total 5 (delta 2), reused 2 (delta 2), pack-reused 3
Unpacking objects: 100% (5/5), done.
From <repo URL>
 * [new branch]      fix/sub-branch          -> origin/fix/sub-branch

이미 답변이 된 것으로 알고 있습니다만, 저에게는 효과가 없었습니다.저는 지역적인 변화는 신경쓰지 않았습니다. 왜냐하면 그것은 이미 추진되었지만 철회하는 데 문제가 있기 때문입니다.저의 경우, "핫픽스"를 분기로 하는 것에서 상위 폴더를 "핫픽스"로 하는 폴더 시스템으로 전환했습니다.

hotfix ----hotfix/1234_bug ----hotfix/3456_bug

그래서 다음과 같은 오류가 발생했습니다.

Fetching from origin Error: cannot lock ref 'refs/remotes/origin/hotfix/1234_bug': 'refs/remotes/origin/hotfix' exists; cannot create 'refs/remotes/origin/hotfix'

유사한 오류를 검색한 후, 저는 마침내 여기에서 토론 스레드에서 해결책을 찾았습니다.

git remote prune origin

이 명령을 사용하여 문제를 해결합니다.

git gc

할 수 없는 개체를 합니다(" " 현재리호리내여핑작하키가실스다업우도행니을해통제수하달고합를개거체없는출을할지러포토지에서호▁(▁to▁invoking▁runby해(통다▁unrekeeping현▁withinachable니▁objects출을▁repos▁and▁the▁remove▁current"를 호출함).git prune그리고.git fsck --unreachable).

보기: 자히보:git help gc(계속) 및git help prune(계속).

git-gc - 불필요한 파일 정리 및 로컬 리포지토리 최적화

git-prune - 연결할 수 없는 모든 개체를 개체 데이터베이스에서 제거합니다.

이름 바꾸기dev/subdev/sub/something그런 다음 분기를 생성할 수 있습니다.dev/sub/master.

Windows 사용자인 저는 지금까지 어떤 솔루션도 문제를 해결하지 못했습니다.이를 본 하여) 지점을 dev/sub하지만 다른 누군가가 그 지점을 만들었습니다.Dev아시다시피 Windows에는 대소문자를 구분하지 않는 파일 시스템이 있습니다.

창이 할 때 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜdev/sub에 처에폴생했습다니고려성하더 를 만들려고 했습니다.dev하지만 그럴 수 없었습니다. 왜냐하면Dev이미 존재했습니다.

은 해책은삭것니다습이었을 하는 것이었습니다.Dev 격원지를 하여 로컬 및 git branch -d Dev && git push origin :Dev.a.git pull이 일이 잘 진행된 후에.

앞으로 또 다른 교훈은 지점 이름이 항상 소문자여야 이런 종류의 gotcha를 피할 수 있다는 것입니다.

그렇지 않으면 리포 시스템에 지점 이름에 대한 제한이 없는지 확인합니다.내경우, 다로시는분기로 수 .SD-<number>다른 이름을 지정하면 다음과 같은 제네릭이 제공됩니다.

remote: error: cannot lock ref 'refs/heads/mybranch': 'refs/heads/mybranch/environment-variables' exists; cannot create 'refs/heads/mybranch'
To git.example.com:project/repository.git
 ! [remote rejected] mybranch -> mybranch (failed to update ref)
error: failed to push some refs to 'git@git.example.com:project/repository.git'
#!/usr/bin/env bash
echo "update-ref delete refs/tags"
log="git-update-ref-errors.log"
script="./git-update-ref-exist-tags-delete.sh"
git_command="git update-ref -d refs/tags"

echo "log errors from ${git_command} to ${log}"
${git_command} 2>&1 | > ${log}
echo "show errors to ${log}"
cat ${log}
echo create ${script}
touch ${script}
echo "add execute (+x) permissions to ${script}"
chmod +x ${script}
echo "generate ${script} from errors log ${log}"
${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script}
echo "execute ${script}"
${script}

echo fetch
log="git-fetch-errors.log"
script="./git-fetch-exist-tags-delete.sh"
git_command="git fetch"
echo "log errors from ${git_command} to ${log}"
${git_command} 2>&1 | > ${log}
echo "show errors from ${log}"
cat ${log}
echo create ${script}
touch ${script}
echo "add execute (+x) permissions to ${script}"
chmod +x ${script}
echo "generate ${script} from errors log ${log}"
${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script}
echo "execute ${script}"
${script}
git fetch

echo pull
log="git-pull-errors.log"
script="./git-pull-exist-tags-delete.sh"
git_command="git pull"
echo "log errors from ${git_command} to ${log}"
${git_command} 2>&1 | > ${log}
echo "show errors from ${log}"
cat ${log}
echo create ${script}
touch ${script}
echo "add execute (+x) permissions to ${script}"
chmod +x ${script}
echo "generate ${script} from errors log ${log}"
${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script}
echo "execute ${script}"
${script}
git pull

echo push
log="git-push-errors.log"
script="./git-push-exist-tags-delete.sh"
git_command="git push"
echo "log errors from ${git_command} to ${log}"
${git_command} 2>&1 | > ${log}
echo "show errors from ${log}"
cat ${log}
echo create ${script}
touch ${script}
echo "add execute (+x) permissions to ${script}"
chmod +x ${script}
echo "generate ${script} from errors log ${log}"
${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script}
echo "execute ${script}"
${script}
git push

위의 스크립트는 XXX-errors.log에 오류를 기록하고 XXX-exist-tags-delete를 생성하고 실행하여 수정합니다.sh는 다음 명령을 사용하여 XXX-errors.log에서 자동으로 생성됩니다.

  1. git update-ref-drefs/message
  2. 기트페치
  3. 기트풀
  4. 기트 푸쉬

git remote prune origin나를 위해 그 문제를 해결했습니다.

git checkout -b hotfix/my-new-branch

ga
gm "my commit"

gp --set-upstream origin hotfix/subscribers-function

언급URL : https://stackoverflow.com/questions/22630404/git-push-refs-heads-my-subbranch-exists-cannot-create

반응형