Git 스위치 분기 오류 오류: pathspec 'XXX'가 git 오류 솔루션에 알려진 파일과 일치하지 않습니다.

머리말

최근에 옆집 그룹을 도와 문제를 해결하고 코드를 감사했는데 코드를 제출하지 않았기 때문에 새 지점으로 전환할 때 오류가 발생했습니다.

질문

로컬로 분기 전환

git checkout xxx

오류 보고

error: pathspec 'XXX' did not match any file(s) known to git

여기에 이미지 설명 삽입

해결하다

1. 모든 지역 지점 보기

모든 로컬 브랜치에서 동료가 생성한 새로운 브랜치가 있는지 확인

git branch -a

2. 모든 지점 가져오기

표시되지 않으면 다음을 수행하십시오. 이 단계는 모든 분기를 가져오는 것입니다.

git fetch

여기에 이미지 설명 삽입

3. 실행 후 프롬프트가 표시됩니다.

remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
Unpacking objects: 100% (4/4), 1.06 KiB | 90.00 KiB/s, done.
From codeup.aliyun.com:5eeb0689892c58bb7c394ab5/pxb/pxb-fronted
 * [new branch]      XXX -> origin/XXX

여기에 이미지 설명 삽입

4. 원격 동료 지점으로 전환

git checkout origin/XXX

힌트

Note: switching to 'origin/XXX'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at dc877cd XXX

5. 새 브랜치를 만들고 동료로 전환

이제 자신의 가지가 숫자와 문자의 문자열임을 알 수 있습니다. 이때 새 가지를 만들고 동료의 가지로 전환하십시오.

git checkout -b XXX

6. 원격 동료 지점과 연결

git branch -u origin/XXX XXX

7. 이제 git pull을 실행할 수 있습니다.

git pull

여기에 이미지 설명 삽입

추천

출처blog.csdn.net/ic_xcc/article/details/124500558