On Mon, 29 Jul 2013 07:33:41 -0700 (PDT)
Ling <oylf1...@gmail.com> wrote:

> When I try to checkout the different branch and I got below errros:
> error: Your local changes to the following files would be overwritten
> by checkout:
> .....
> how do I get this working so I can switch branches?

Let's cite the manual:

   git checkout <branch>

       To prepare for working on <branch>, switch to it by updating the
   index and the files in the working tree, and by pointing HEAD at the
   branch. Local modifications to the files in the working tree are
   kept, so that they can be committed to the <branch>.

and then


      When switching branches, if you have local modifications to one or
  more files that are different between the current branch and the
  branch to which you are switching, the command refuses to switch
  branches in order to preserve your modifications in context. However,
  with this option, a three-way merge between the current branch, your
  working tree contents, and the new branch is done, and you will be on
  the new branch.

So, Git refuses to check out your branch because it can't reconcile the
prospective changes to certain files the new branch is about to bring
in with the local uncommitted changes you have in your work tree (and
possibly in the index).

Now you have several options.  Which option to pick depends on what
outcome of your prospective actions is desired, and you did not tell us
about this.  The options are:

1) Commit your changes.  This will let the checkout operation to proceed
   by just replacing the files in the index and the work tree with their
   contents as recorded in the tip commit of the branch to be checked
   out, as usually.

2) Stash your changes.  This will make your local changes to disappear
   from the work tree and the index, again, letting the branch switching
   to proceed.  You will then have to decide what to do with these
   stashed changes.

2a) Stash your changes, check out another branch then unstash the
    changes.  This operation is guaranteed to result in merge conflicts
    with which you will have to deal.

3) Use `git checkout --merge <branch>` and deal with merge conflicts
   right away.  These will be somewhat "reversed" to those which would
   occur should you pick (2a) because the order of application of the
   actual textual changes will be reversed.  But essentially these will
   be the same conflicts (touching the same parts of the same files).

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to