From: Thomas Rast <trast@student.ethz.ch>
To: geoffrey.russell@gmail.com
Cc: git@vger.kernel.org,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Jakub Narebski <jnareb@gmail.com>
Subject: Re: Tracking the untracked
Date: Thu, 7 May 2009 11:16:56 +0200 [thread overview]
Message-ID: <200905071117.00162.trast@student.ethz.ch> (raw)
In-Reply-To: <93c3eada0905070058g7f619a56jfb9b49f02bb92f9b@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2531 bytes --]
Geoff Russell wrote:
>
Please keep the Cc list, it's customary around here and helps us find
the mails addressed to us.
> On 5/6/09, Thomas Rast <trast@student.ethz.ch> wrote:
> > Your build products became tracked (w.r.t. the then-state of the
> > repository, on branch B1) the second you added them to the index with
> > 'git add'. Git then cares about them, and among many other things
> > will look at them whenever you change branches. Since they're not
> > present in the target branch 'master', they are removed from the work
> > tree.
[...]
> Ok, its clearly a policy choice. But suppose I have an untracked
> file and I do "git some-command" then I don't expect git to touch what
> it doesn't know about. I.e., "git add x" shouldn't delete the untracked
> file y. That seems sensible. But now "git checkout branch" behaves
> quite differently in just deleting stuff that it doesn't own (i.e., is
> untracked).
>
> Anyway, I'll rethink.
They weren't untracked!
This is roughly what Dscho said, but I'll try to explain it in more
detail:
- In the first step, when switching from master to B1, your build
products were indeed untracked (not part of either master or B1 or
the index). So Git leaves them alone.
- By adding (git add $file) your files to the index, you made them
tracked.[1]
- By making a commit, you let the files "officially" belong to the
current branch (B1). So with respect to the _current_ branch B1,
they _were_ tracked.
- When you switch branches in the last step, Git sees that B1 has
these files, but master doesn't, so it removes them to bring the
worktree into the state that master has.
- Consider what happens if you were to recompile at this point, so
that you again have the _untracked_ (w.r.t. the 'master' branch)
build products, and then check out B1 again. Git faces the choice
of either overwriting your worktree files (and losing them) or not
overwriting (and not doing the checkout right), so it will abort.
This is a corollary of what Jakub pointed out, Git will not lose
information unless told to.
[1] If you were to switch branches at this point, without making a
commit, Git tries to "carry over" the addition of files to the target
branch, unless it conflicts with files in that target branch, so the
index is in a slightly different position than the HEAD. Still,
anything that is listed in the index is considered tracked.
--
Thomas Rast
trast@{inf,student}.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-05-07 9:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-06 1:19 Tracking the untracked Geoff Russell
2009-05-06 9:36 ` Johannes Schindelin
2009-05-06 13:22 ` Thomas Rast
2009-05-07 7:58 ` Geoff Russell
2009-05-07 8:22 ` Jakub Narebski
2009-05-07 9:16 ` Thomas Rast [this message]
2009-05-07 10:54 ` Geoff Russell
-- strict thread matches above, loose matches on Subject: below --
2009-05-31 23:10 Giuseppe Bilotta
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=200905071117.00162.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=Johannes.Schindelin@gmx.de \
--cc=geoffrey.russell@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@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).