IT story

“경로를 업데이트하고 동시에 지점으로 전환 할 수 없습니다”

hot-time 2020. 5. 20. 07:57
반응형

“경로를 업데이트하고 동시에 지점으로 전환 할 수 없습니다”


때로는 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브랜치를 가져 왔는지 확인하기 위해 )


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. After verifying the details like (fetch URL, etc), run this command to fetch any new branch(i.e. which you may want to checkout in your local repo) that exist in the remote but not in your local.
» git remote update

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

As you can see the new branch has been fetched from remote.
3. Finally, checkout the branch with this command

» git checkout -b Feature3 origin/Feature3

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

It is not necessary to explicitly tell Git to track(using --track) the branch with remote.

The above command will set the local branch to track the remote branch from origin.


If you got white space in your branch then you will get this error.


For me I needed to add the remote:

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

then I could fetch

git fetch myRemoteName

First you need to Fetch the remote (the specific branch), then you can create a local br and track it with that remote branch using your command (i.e. checkout with -b and --track).


You should go the submodule dir and run git status.

You may see a lot of files were deleted. You may run

  1. git reset .

  2. git checkout .

  3. git fetch -p

  4. git rm --cached submodules //submoudles is your name

  5. git submoudle add ....


You can use these commands: git remote update, git fetch, git checkout -b branch_nameA origin:branch_nameB

I think maybe it's because of your local branch can not track remote branch


It causes by that your local branch doesn't track remote branch. As ssasi said,you need use these commands:

git remote update
git fetch
git checkout -b branch_nameA origin/branch_nameB

I solved my problem just now....

참고URL : https://stackoverflow.com/questions/22984262/cannot-update-paths-and-switch-to-branch-at-the-same-time

반응형