git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Deleted folder keeps showing up?

From
Benjamin Buch <benni.buch@gmx.de>
Date
Sep 7, 2009, 08:17 UTC
Message-ID
<53F9526D-E31D-4027-8871-8468AB476E6D@gmx.de>
In-Reply-To
<7vfxb3yuma.fsf@alter.siamese.dyndns.org>
Hi Junio,
thanks for the explanation!

It made things a lot clearer for me. And I think that could be exactly what happened and the reason why I couldn't reproduce the 'error'.

-benjamin
Am 04.09.2009 um 10:36 schrieb Junio C Hamano:
Show 78 quoted lines
> 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.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Junio C HamanoNext: Jeff King
Message 5 of 6 in “Deleted folder keeps showing up?”
  1. Benjamin BuchSep 3, 2009
  2. Michael J GruberSep 4, 2009
  3. Benjamin BuchSep 4, 2009
  4. Junio C HamanoSep 4, 2009
  5. Benjamin BuchSep 7, 2009
  6. Jeff KingSep 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.