[git] Git checkout: updating paths is incompatible with switching branches

My problem is related to Fatal Git error when switching branch.

I try to fetch a remote branch with the command

git checkout -b local-name origin/remote-name

but I get this error message:

fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/remote-name' which can not be resolved as commit?

If I manually create a branch and then pull the remote branch, it works, just as making a new clone and checking the branch out.

Why does it not work on the repository I work with?

This question is related to git git-checkout remote-branch

The answer is


For me what worked was:

git fetch

Which pulls all the refs down to your machine for all the branches on remote. Then I could do

git checkout <branchname>

and that worked perfectly. Similar to the top voted answer, but a little more simple.


I suspect there is no remote branch named remote-name, but that you've inadvertently created a local branch named origin/remote-name.

Is it possible you at some point typed:

git branch origin/remote-name

Thus creating a local branch named origin/remote-name? Type this command:

git checkout origin/remote-name

You'll either see:

Switched to branch "origin/remote-name"

which means it's really a mis-named local branch, or

Note: moving to "origin/rework-isscoring" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b 

which means it really is a remote branch.


Could your issue be linked to this other SO question "checkout problem"?

i.e.: a problem related to:

  • an old version of Git
  • a curious checkout syntax, which should be: git checkout -b [<new_branch>] [<start_point>], with [<start_point>] referring to the name of a commit at which to start the new branch, and 'origin/remote-name' is not that.
    (whereas git branch does support a start_point being the name of a remote branch)

Note: what the checkout.sh script says is:

  if test '' != "$newbranch$force$merge"
  then
    die "git checkout: updating paths is incompatible with switching branches/forcing$hint"
  fi

It is like the syntax git checkout -b [] [remote_branch_name] was both renaming the branch and resetting the new starting point of the new branch, which is deemed incompatible.


Alternate syntax,

git fetch origin remote_branch_name:local_branch_name

After fetching a zillion times still added remotes didn't show up, although the blobs were in the pool. Turns out the --tags option shouldn't be given to git remote add for whatever reason. You can manually remove it from the .git/config to make git fetch create the refs.


It's not very intuitive but this works well for me ...

  mkdir remote.git & cd remote.git & git init
  git remote add origin $REPO
  git fetch origin $BRANCH:refs/remotes/origin/$BRANCH        

THEN run the git branch --track command ...

  git branch --track $BRANCH origin/$BRANCH

For me I had a typo and my remote branch didn't exist

Use git branch -a to list remote branches


Not sure if this is helpful or exactly relevant to your question, but if you are trying to fetch and checkout only a single branch from the remote repository, then the following git commands will do the trick:

url= << URL TO REPOSITORY >>
branch= << BRANCH NAME >>

git init
git remote add origin $url
git fetch origin $branch:origin/$branch
git checkout -b $branch --track origin/$branch

none of the above worked for me. My situation is slightly different, my remote branch is not at origin. but in a different repository.

git remote add remoterepo GIT_URL.git
git fetch remoterepo
git checkout -b branchname remoterepo/branchname

tip: if you don't see the remote branch in the following output git branch -v -a there is no way to check it out.

Confirmed working on 1.7.5.4


After having tried most of what I could read in this thread without success, I stumbled across this one: Remote branch not showing up in "git branch -r"

It turned out that my .git/config file was incorrect. After doing a simple fix all branches showed up.

Going from

[remote "origin"]
    url = http://stash.server.com/scm/EX/project.git
    fetch = +refs/heads/master:refs/remotes/origin/master

to

[remote "origin"]
    url = http://stash.server.com/scm/EX/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Did the trick


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to git-checkout

How can I switch to another branch in git? Git checkout - switching back to HEAD What is git tag, How to create tags & How to checkout git remote tag(s) How can I move HEAD back to a previous location? (Detached head) & Undo commits error: pathspec 'test-branch' did not match any file(s) known to git git checkout all the files How can I check out a GitHub pull request with git? "Cannot update paths and switch to branch at the same time" error: Your local changes to the following files would be overwritten by checkout Git command to checkout any branch and overwrite local changes

Examples related to remote-branch

When does Git refresh the list of remote branches? What are the differences between git remote prune, git prune, git fetch --prune, etc Git: Cannot see new remote branch Update a local branch with the changes from a tracked remote branch Git: which is the default configured remote for branch? How do I list all remote branches in Git 1.7+? How do I check out a remote Git branch? How do you remove an invalid remote branch reference from Git? Git checkout: updating paths is incompatible with switching branches How to clone all remote branches in Git?