“경로를 업데이트하고 동시에 지점으로 전환 할 수 없습니다” 하는 옵션을 사용합니다. 새로운 환경 에서이 오류가

때로는 checkout -b새 지점을 생성하고 동시에 체크 아웃하고 하나의 명령으로 추적을 설정 하는 옵션을 사용합니다.

새로운 환경 에서이 오류가 발생합니다.

$ git checkout -b test --track origin/master
fatal: Cannot update paths and switch to branch 'test' at the same time.
Did you intend to checkout 'origin/master' which can not be resolved as commit?

Git이 왜 좋아하지 않습니까? 이것은 동일한 리포지토리에서 작동했습니다.



답변

origin/master커밋으로 해결할 수없는 ‘ ‘

이상 : 리모컨을 확인해야합니다.

git remote -v

그리고 origin가져 왔는지 확인하십시오 .

git fetch origin

그때:

git branch -avv

( origin/master브랜치를 가져 왔는지 확인하기 위해 )

마지막으로 혼란스러운git switch 대신 Git 2.23+ (2019 년 8 월)를 사용하십시오.git checkout

git switch -c test --track origin/master

답변

FWIW : 지점 이름에 오타가있는 경우 이와 동일한 오류가 발생합니다.


답변

예를 들어 기본적으로 코드를 체크 아웃하는 Travis 빌드와 같은 상황에서이 오류가 발생할 수 있습니다 git clone --depth=50 --branch=master. 내가 아는 한,를 --depth통해 제어 할 수 는 .travis.yml있지만 --branch. 그 결과 리모콘에서 단일 분기 만 추적하므로 원하는 리모콘 참조를 추적하도록 리모콘을 독립적으로 업데이트해야합니다.

전에:

$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master

수정 :

$ git remote set-branches --add origin branch-1
$ git remote set-branches --add origin branch-2
$ git fetch

후:

$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/branch-1
remotes/origin/branch-2
remotes/origin/master

답변

이 간단한 일은 나를 위해 일했습니다!

동시에 두 가지 작업을 수행 할 수 없다고 표시되면 분리하십시오.

git branch branch_name origin/branch_name

git checkout branch_name

답변

이 문제를 발견하면 다음 단계를 수행 할 수 있습니다.

  1. 다음 명령을 실행하여 로컬 저장소로 알려진 분기를 나열하십시오.

git remote show origin

이것은 이것을 출력합니다 :

 remote origin
  Fetch URL: <your_git_path>
  Push  URL: <your_git_path>
  HEAD branch: development
  Remote branches:
    development                             tracked
    Feature2                                tracked
    master                                  tracked
    refs/remotes/origin/Feature1         stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    Feature2     merges with remote Feature2
    development  merges with remote development
    master       merges with remote master
  Local refs configured for 'git push':
    Feature2     pushes to Feature2     (up to date)
    development  pushes to development (up to date)
    master       pushes to master      (local out of date)
  1. (URL 가져 오기 등) 세부 사항을 확인한 후이 명령을 실행하여 원격에 있지만 로컬에는없는 새 분기 (예 : 로컬 저장소에서 체크 아웃하려는 경우)를 가져옵니다.
» git remote update

Fetching origin
From gitlab.domain.local:ProjectGroupName/ProjectName
 * [new branch]      Feature3    -> Feature3

보시다시피 새 브랜치가 원격에서 가져 왔습니다.
3. 마지막 으로이 명령으로 지점을 체크 아웃하십시오.

» git checkout -b Feature3 origin/Feature3

Branch Feature3 set up to track remote branch Feature3 from origin.
Switched to a new branch 'Feature3'

원격으로 분기 를 추적 ( –track 사용 )하도록 Git에 명시 적으로 지정할 필요는 없습니다 .

위의 명령은 로컬 브랜치를 원점에서 원격 브랜치를 추적하도록 설정합니다.


답변

지점에 공백이 있으면이 오류가 발생합니다.


답변

나를 위해 리모컨을 추가해야했습니다.

git remote -add myRemoteName('origin' in your case) remoteGitURL

그런 다음 가져올 수 있습니다

git fetch myRemoteName