git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Leila <muhtasib@gmail.com>
Cc: konglu@minatec.inpg.fr, "Cláudio Lourenço" <pt.smooke@gmail.com>,
	git@vger.kernel.org, "Renato Neves" <nevrenato@gmail.com>
Subject: Re: Help understanding git checkout behavior
Date: Mon, 11 Jun 2012 14:55:07 -0400	[thread overview]
Message-ID: <20120611185507.GF20134@sigill.intra.peff.net> (raw)
In-Reply-To: <CAA3EhH+iD-sS-3Sg4HJDHgs4Deg2=qbCuJD4UwZWtGQsKbV5aA@mail.gmail.com>

On Mon, Jun 11, 2012 at 02:34:01PM -0400, Leila wrote:

> When you create a branch, it will contain everything committed on the
> branch you created it from at that given point. So if you commit more
> things on the master branch like you have done (after creating b),
> then switch to branch b, they won't appear. This is the correct
> behavior. Does that answer your question?

No, the problem is more subtle:

> >> smooke  teste $ git rm something
> >> rm 'something'
> >> smooke  teste $ mkdir something
> >> smooke  teste $ cd something/
> >> smooke  something $ touch f1
> >> smooke  something $ echo c > f1
> >> smooke  something $ cd ..
> >> smooke  teste $ git add something/f1
> >> smooke  teste $ git checkout b
> >> Switched to branch 'b'
> >> smooke  teste $ ls
> >> f

We have lost "something/f1" during the switch, which was not committed
anywhere. This is presumably an error because we see that "something"
used to be tracked, and now we are tracking something different there.

If we had put some new content into the file "something", git would
rightfully complain with:

  $ git checkout b
  error: Your local changes to the following files would be overwritten
  by checkout:
          something
  Please, commit your changes or stash them before you can switch branches.
  Aborting

But it misses the case when "something" switches from a file into a
directory, which is probably a bug.

-Peff

  reply	other threads:[~2012-06-11 18:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-11 16:52 Help understanding git checkout behavior Cláudio Lourenço
2012-06-11 17:07 ` Konstantin Khomoutov
2012-06-11 18:21 ` konglu
2012-06-11 18:34   ` Leila
2012-06-11 18:55     ` Jeff King [this message]
2012-06-11 18:56     ` Junio C Hamano
2012-06-11 20:48       ` Cláudio Lourenço
2012-06-11 21:04         ` Junio C Hamano
2012-06-11 21:34           ` Junio C Hamano
2012-06-11 21:47             ` Jeff King
2012-06-11 21:58               ` Jeff King
2012-06-11 22:45               ` Junio C Hamano
2012-06-11 18:52 ` Vincent van Ravesteijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120611185507.GF20134@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=konglu@minatec.inpg.fr \
    --cc=muhtasib@gmail.com \
    --cc=nevrenato@gmail.com \
    --cc=pt.smooke@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).