Sometimes git can be as dark and mysterious as Dan Brown’s popularity as a novelist. I was struggling with retrieving a newly created remote branch:

git checkout –track -b screensizes origin/screensizes

Which rendered:
fatal: git checkout: updating paths is incompatible with switching branches/forcing

Which is as clear as mud. Googling was fruitless until I found this suggestion:

[Switch to the root directory that your tracking]

$ git checkout -f master
$ git pull

(Note: this errored for me, since I haven’t established nicknames)

$ git checkout --track -b

Then worked. Dunno why, but worth a shot if your stuck on this mesage.

6 Responses to “fatal: git checkout problem resolved”

  1. You are my saviour!
    Thanks!

  2. bkidd says:

    It’s –track instead of -track. Also, –track has to be passed before -b.

    So it’s => git checkout –track -b

    i.e. => git checkout –track -b new_branch origin/new_branch

  3. bkidd says:

    Looks like I’ll have to use html character codes…

    It’s --track instead of -track. Also, --track has to be passed before -b.

    So it’s => git checkout --track -b <new_local_branch> <start_point>

    i.e. => git checkout --track -b new_branch origin/new_branch

  4. bkidd says:

    Oh, as for the reason it worked, it was due to the “git pull” you did. Switching to master should not have mattered. Even though you could see the remote branch with a “git branch -r”, you still have to issue a “git pull” (from any branch) to pull in the latest listing of remote branches to your local repo. Then you can checkout the new remote branch.

  5. Martin says:

    Just a note: if you want to track a branch from another repo than origin, you have to issue a

    git fetch reponame

    before. Just happened to me…

  6. Max Williams says:

    Thanks for this, sort of makes sense in hindsight but not at all obvious.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Performance Optimization WordPress Plugins by W3 EDGE