git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Benjamin Buch <benni.buch@gmx.de>
Cc: Michael J Gruber <git@drmicha.warpmail.net>, git@vger.kernel.org
Subject: Re: Deleted folder keeps showing up?
Date: Fri, 04 Sep 2009 01:36:13 -0700	[thread overview]
Message-ID: <7vfxb3yuma.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 8E56979B-5D85-4844-A492-8149EE9E9B2F@gmx.de

Benjamin Buch <benni.buch@gmx.de> writes:

> Strangely, I can't reproduce the error  today.

If a branch has dir/file tracked, and another branch does not have
anything tracked in dir/ directory at all, then switching from the former
branch to the latter can remove dir/ only when you do not have any
untracked files in there when you switch.  Otherwise dir/ must stay
behind to keep the untracked files.

You can see it by a simple experiment.

    $ rm -fr trial
    $ mkdir trial
    $ cd trial
    $ git init
    $ >elif
    $ git commit -m initial
    $ git branch lacksdir
    $ mkdir dir
    $ >dir/file
    $ git add dir/file
    $ git commit -m add-dir-file

Now, after this set-up, your 'master' has dir/file and 'lacksdir' does
not have anything tracked in dir/ directory.

Observe:

    $ git checkout lacksdir
    $ find ??*
    elif
    $ git checkout master
    $ find ??*
    dir
    dir/file
    elif
    $ >dir/garbage
    $ git checkout lacksdir
    $ find ??*
    dir
    dir/garbage
    elif

If switching to 'lacksdir' removed the dir/ directory, whatever was in the
untracked file dir/garbage will be lost.  In the above exercise, I named
it garbage, so a casual reader might get a false impression that it should
be thrown away, but in real life workflow, it often happens that

 (1) you start doing some interesting experimental changes, while on
     'master';

 (2) you realize that this change does not belong to 'master', but belongs
     to some other branch, perhaps 'lacksdir';

 (3) you switch to the branch, to keep working.

Remember that, in git, your uncommitted changes to the index and the work
tree do not belong to the branch.  They try to follow you across branch
switching.  Since untracked new files are something potentially you might
want to add after branch switching, we do not remove them.  And because we
choose not to remove dir/file, even though the commit at the tip of the
lacksdir branch does not have anything tracked in dir/ directory, we
cannot remove it from the work tree.

  reply	other threads:[~2009-09-04  8:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-03 16:59 Deleted folder keeps showing up? Benjamin Buch
2009-09-04  7:41 ` Michael J Gruber
2009-09-04  8:18   ` Benjamin Buch
2009-09-04  8:36     ` Junio C Hamano [this message]
2009-09-07  8:17       ` Benjamin Buch
2009-09-04  8:27 ` Jeff King

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=7vfxb3yuma.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=benni.buch@gmx.de \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    /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).