All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: david@lang.hm
Cc: Andrew Morton <akpm@linux-foundation.org>, git@vger.kernel.org
Subject: Re: Untracked working tree files
Date: Wed, 15 Oct 2008 12:56:26 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.0810151247560.3288@nehalem.linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.1.10.0810151240220.7808@asgard.lang.hm>



On Wed, 15 Oct 2008, david@lang.hm wrote:
> 
> I see it fairly frequently when switching between different branches of a
> project.

So, at least for any normal switch, assuming file 'a' doesn't exist in the 
other branch, you really should have a few different cases:

 - you have a dirty file, and git should say something like

	error: You have local changes to 'file'; cannot switch branches.

   because it refuses to modify the file to match the other branch (which 
   includes removing it) if it doesn't match the index.

   So this case shouldn't leave anything behind.

 - You have that extra file, but it's not in the index.

   If it's in your current HEAD, we should still notice it with something 
   like:

	error: Untracked working tree file 'tree' would be removed by merge.

   because now it's untracked (not in the index), but the switching 
   between branches tries to essentially "apply" the difference between 
   your current HEAD and the new branch, and finds that the difference 
   involves removing a file that git isn't tracking.

See?

HOWEVER.

If you're used to doing "git checkout -f" or "git reset --hard", both of 
those checks are just ignored. After all, you asked for a forced switch. 

And at least in the second case, what I think happens is that git won't 
remove the file it doesn't know about, so you'll have a "turd" left 
around.

So yes, you can certainly get these kinds of left-overs, but they really 
should be only happening if you "force" something. Do you do that often?

			Linus

  reply	other threads:[~2008-10-15 19:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 18:56 Untracked working tree files Andrew Morton
2008-10-15 19:09 ` david
2008-10-15 19:14   ` david
2008-10-15 19:24     ` Andrew Morton
2008-10-15 19:26     ` Andrew Morton
2008-10-15 19:32       ` Nicolas Pitre
2008-10-15 19:34         ` Nicolas Pitre
2008-10-15 19:31     ` Linus Torvalds
2008-10-15 19:42       ` david
2008-10-15 19:56         ` Linus Torvalds [this message]
2008-10-15 20:17           ` david
2008-10-15 19:49       ` Andrew Morton
2008-10-15 20:08         ` Linus Torvalds
2008-10-15 20:23           ` Andrew Morton
2008-10-16  8:42             ` Paolo Ciarrocchi
2008-10-16  9:32               ` Andrew Morton
2008-10-15 20:23           ` Linus Torvalds
2008-10-15 20:30             ` Andrew Morton
2008-10-15 22:06             ` Junio C Hamano
2008-10-15 23:00               ` [PATCH] reset --hard/read-tree --reset -u: remove unmerged new paths Junio C Hamano
2008-10-15 23:16                 ` Linus Torvalds
2008-10-16  6:27                   ` Junio C Hamano
2008-10-16  7:20                 ` Ingo Molnar
2008-10-16 14:49                   ` Junio C Hamano

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=alpine.LFD.2.00.0810151247560.3288@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@lang.hm \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.