why i cannot checkout another git branch?

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

$ git checkout lab_master
error: Your local changes to the following files would be overwritten by checkou                                                                                                                           t:
        **project.properties**
Please, commit your changes or stash them before you can switch branches.
Aborting

why i just failed to checkout lab_master branch?

another question: why i cannot compare current file with the file in another branch?

  • Team City pending changes for specific build configuration is not as per default branch
  • Concurrent git clone and fetch
  • Confused on checking out in Git
  • How to log every branch last commit time?
  • How to resolve conflict of renamed folder of file in git?
  • Run Lint from console for only selected files
  • $ git diff project.properties -b lab_master
    fatal: bad flag '-b' used after filename
    

  • Allow agent forwarding using Cmder (ConEmu)
  • Git branch as submodule to own repository
  • How to handle monolithic project in one root in jenkins with gradle?
  • Why does Heroku fail to detect Node.js buildpack?
  • GitHub compare view for current versions of branches
  • How to verify a git merge contains no extra changes?
  • 3 Solutions collect form web for “why i cannot checkout another git branch?”

    Git protects you from switching to another branch, because that would override some changes you applied to the file project.properties. You can either throw the changes away by using git checkout -f lab_master or stash them first via git stash (and git stash pop after you checked out the other branch.) If you are sure, you want to keep the changes, you can also simply commit them.

    You need to either commit your changes or stash them, http://git-scm.com/book/en/Git-Tools-Stashing

    git diff already uses the -b flag to ignore whitespace.
    That conflicts with your desire to refer to another branch.
    For that you need to use ‘git diff master..anotherbranch’

    Git Baby is a git and github fan, let's start git clone.