From: Junio C Hamano <junkio@cox.net>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: git@vger.kernel.org
Subject: Re: git checkout -f branch doesn't remove extra files
Date: Fri, 12 Aug 2005 13:27:41 -0700 [thread overview]
Message-ID: <7v8xz6uchu.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: B8E391BBE9FE384DAA4C5C003888BE6F04214AC7@scsmsx401.amr.corp.intel.com
"Luck, Tony" <tony.luck@intel.com> writes:
> I see that when I switch view to a different
> branch with:
>
> $ git checkout -f someoldbranch
>
> that any files that exist in my previous branch view
> but not in "someoldbranch" are not deleted.
>
> ... I wondered whether this was a deliberate choice
Not really.
When possible, please use "git checkout" without -f. That form
uses "git-read-tree -u -m", which can tell from your current
index file what's changed and what's going away. This is only
possible if read-tree can rely on what is in your index file
actually matches the status of your working tree, and the -f
flag to checkout is to work around cases where you cannot give
that guarantee to read-tree and would want/need to start over
from scratch. With -f flag, you are telling git-read-tree to
ignore what is currently recorded in your index file, hence what
should be in your working tree before checkout. There is no way
for git-read-tree to tell which are source files that exist only
in the old thing you had checked out before (i.e. should be
removed) and which are files your build procedure left and/or
files you made by hand outside of SCM control (i.e. should be
kept) without that information, so that is why those files were
left behind.
prev parent reply other threads:[~2005-08-12 20:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-12 17:31 git checkout -f branch doesn't remove extra files Luck, Tony
2005-08-12 20:27 ` Junio C Hamano [this message]
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=7v8xz6uchu.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=tony.luck@intel.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