“Cannot update paths and switch to branch at the s

2019-01-10 00:17发布

I sometimes use the checkout -b option to create a new branch, check it out at the same time and set up tracking in one command.

In a new environment, I get this error:

$ 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?

Why does Git not like it? This used to work with the same repo.

10条回答
霸刀☆藐视天下
2楼-- · 2019-01-10 01:17

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 ....

查看更多
Summer. ? 凉城
3楼-- · 2019-01-10 01:17

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

查看更多
萌系小妹纸
4楼-- · 2019-01-10 01:23

'origin/master' which can not be resolved as commit

Strange: you need to check your remotes:

git remote -v

And make sure origin is fetched:

git fetch origin

Then:

git branch -avv

(to see if you do have fetched an origin/master branch)

查看更多
太酷不给撩
5楼-- · 2019-01-10 01:23

For me I needed to add the remote:

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

then I could fetch

git fetch myRemoteName
查看更多
登录 后发表回答