{"thread":{"id":"19193","subject":"Tracking the untracked","startedAt":"2009-05-06T01:19:34Z","lastAt":"2009-05-07T10:54:30Z","messageCount":7,"participants":["Geoff Russell","Johannes Schindelin","Thomas Rast","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"113063","messageId":"93c3eada0905051819l92dc7ey331d69f009cc9c8b@mail.gmail.com","threadId":"19193","inReplyTo":null,"subject":"Tracking the untracked","fromName":"Geoff Russell","fromEmail":"geoffrey.russell@gmail.com","sentAt":"2009-05-06T01:19:34Z","receivedAt":"2009-05-06T01:19:34Z","isPatch":false,"sender":{"key":"geoffrey.russell@gmail.com","avatar":"https://gravatar.com/avatar/c30f497ccfa6bf06d86f30bd2ba092a2dd124c61c6bc902f7cb5c3f6486947de?d=mp&s=160"},"body":"Bug or feature? I don't know.\n\nOn the master branch I have some untracked files e.g., object modules,\nexecutables.\n\nI create a branch B1 and add+commit the untracked files.\n\nWhen I switch back to the master (git checkout master), the untracked\nfiles are no longer where I left them.\n\nBasically, I'm trying to find a way of having a huge bunch of stuff in\nmy repository and\ntracked, but which doesn't get pushed to the central program repository .. which\nhas always just been source for us .. I figured I could stick it on a\nbranch which doesn't get pushed.\nBut that doesn't work for the reason mentioned.\n\nOne solution would be to have a class of files that is \"unversioned\nbut tracked\".\n\nAlternatively we could just bite the bullet and track everything.\n\nAny ideas?\n\nCheers,\nGeoff Russell\n"},{"id":"113075","messageId":"alpine.DEB.1.00.0905061130340.14230@intel-tinevez-2-302","threadId":"19193","inReplyTo":"93c3eada0905051819l92dc7ey331d69f009cc9c8b@mail.gmail.com","subject":"Re: Tracking the untracked","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-05-06T09:36:17Z","receivedAt":"2009-05-06T09:36:17Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 6 May 2009, Geoff Russell wrote:\n\n> Bug or feature? I don't know.\n> \n> On the master branch I have some untracked files e.g., object modules,\n> executables.\n> \n> I create a branch B1 and add+commit the untracked files.\n> \n> When I switch back to the master (git checkout master), the untracked\n> files are no longer where I left them.\n\nThis is exactly what Git is supposed to do.  You were on branch B1, which \nhas the files tracked, and you do not have the files tracked in master, so \nwhen switching to master, they should be removed.\n\nProbably you have to rethink what you are trying to do.\n\nCiao,\nDscho\n"},{"id":"113080","messageId":"200905061522.56981.trast@student.ethz.ch","threadId":"19193","inReplyTo":"93c3eada0905051819l92dc7ey331d69f009cc9c8b@mail.gmail.com","subject":"Re: Tracking the untracked","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-05-06T13:22:49Z","receivedAt":"2009-05-06T13:22:49Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Geoff Russell wrote:\n> Bug or feature? I don't know.\n\nFeature.\n\n> On the master branch I have some untracked files e.g., object modules,\n> executables.\n> \n> I create a branch B1 and add+commit the untracked files.\n> \n> When I switch back to the master (git checkout master), the untracked\n> files are no longer where I left them.\n[...]\n> One solution would be to have a class of files that is \"unversioned\n> but tracked\".\n\nNote that \"versioned\" and \"tracked\" mean the same thing in Git --\nboth denote the class of files it cares about.\n\nYour build products became tracked (w.r.t. the then-state of the\nrepository, on branch B1) the second you added them to the index with\n'git add'.  Git then cares about them, and among many other things\nwill look at them whenever you change branches.  Since they're not\npresent in the target branch 'master', they are removed from the work\ntree.\n\n> Basically, I'm trying to find a way of having a huge bunch of stuff in\n> my repository and\n> tracked, but which doesn't get pushed to the central program repository .. which\n> has always just been source for us .. I figured I could stick it on a\n> branch which doesn't get pushed.\n> But that doesn't work for the reason mentioned.\n\nMost people just put their build products in .gitignore so that they\nstop showing up under \"untracked files\" in 'git status'.  (They'll\nstill be untracked!)\n\nOf course this means the object files for source that actually changed\nbetween the branches have to be rebuilt.  However, Git takes great\ncare to not touch any source files that are the same, so that the\nbuilds are usually quite fast even after a branch switch.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"113178","messageId":"93c3eada0905070058g7f619a56jfb9b49f02bb92f9b@mail.gmail.com","threadId":"19193","inReplyTo":"200905061522.56981.trast@student.ethz.ch","subject":"Re: Tracking the untracked","fromName":"Geoff Russell","fromEmail":"geoffrey.russell@gmail.com","sentAt":"2009-05-07T07:58:59Z","receivedAt":"2009-05-07T07:58:59Z","isPatch":false,"sender":{"key":"geoffrey.russell@gmail.com","avatar":"https://gravatar.com/avatar/c30f497ccfa6bf06d86f30bd2ba092a2dd124c61c6bc902f7cb5c3f6486947de?d=mp&s=160"},"body":"On 5/6/09, Thomas Rast <trast@student.ethz.ch> wrote:\n> Geoff Russell wrote:\n>  > Bug or feature? I don't know.\n>\n>\n> Feature.\n>\n>\n>  > On the master branch I have some untracked files e.g., object modules,\n>  > executables.\n>  >\n>  > I create a branch B1 and add+commit the untracked files.\n>  >\n>  > When I switch back to the master (git checkout master), the untracked\n>  > files are no longer where I left them.\n>\n> [...]\n>\n> > One solution would be to have a class of files that is \"unversioned\n>  > but tracked\".\n>\n>\n> Note that \"versioned\" and \"tracked\" mean the same thing in Git --\n>  both denote the class of files it cares about.\n>\n>  Your build products became tracked (w.r.t. the then-state of the\n>  repository, on branch B1) the second you added them to the index with\n>  'git add'.  Git then cares about them, and among many other things\n>  will look at them whenever you change branches.  Since they're not\n>  present in the target branch 'master', they are removed from the work\n>  tree.\n>\n>\n>  > Basically, I'm trying to find a way of having a huge bunch of stuff in\n>  > my repository and\n>  > tracked, but which doesn't get pushed to the central program repository .. which\n>  > has always just been source for us .. I figured I could stick it on a\n>  > branch which doesn't get pushed.\n>  > But that doesn't work for the reason mentioned.\n>\n>\n> Most people just put their build products in .gitignore so that they\n>  stop showing up under \"untracked files\" in 'git status'.  (They'll\n>  still be untracked!)\n>\n>  Of course this means the object files for source that actually changed\n>  between the branches have to be rebuilt.  However, Git takes great\n>  care to not touch any source files that are the same, so that the\n>  builds are usually quite fast even after a branch switch.\n>\n\nOk, its clearly a policy choice.  But suppose I have an untracked\nfile and I do \"git some-command\" then I don't expect git to touch what\nit doesn't know about. I.e., \"git add x\" shouldn't delete the untracked\nfile y. That seems sensible. But now \"git checkout branch\" behaves\nquite differently in just deleting stuff that it doesn't own (i.e., is\nuntracked).\n\nAnyway, I'll rethink.\n\nCheers,\nGeoff.\n\n>\n>  --\n>  Thomas Rast\n>  trast@{inf,student}.ethz.ch\n>\n>\n\n\n-- \n6 Fifth Ave,\nSt Morris, S.A. 5068\nAustralia\nPh: 041 8805 184 / 08 8332 5069\n"},{"id":"113180","messageId":"m33abhnx01.fsf@localhost.localdomain","threadId":"19193","inReplyTo":"93c3eada0905070058g7f619a56jfb9b49f02bb92f9b@mail.gmail.com","subject":"Re: Tracking the untracked","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-05-07T08:22:43Z","receivedAt":"2009-05-07T08:22:43Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Geoff Russell <geoffrey.russell@gmail.com> writes:\n> On 5/6/09, Thomas Rast <trast@student.ethz.ch> wrote:\n> > Geoff Russell wrote:\n\n> > > Bug or feature? I don't know.\n> >\n> >\n> > Feature.\n\n[...]\n> Ok, its clearly a policy choice.  But suppose I have an untracked\n> file and I do \"git some-command\" then I don't expect git to touch what\n> it doesn't know about. I.e., \"git add x\" shouldn't delete the untracked\n> file y. That seems sensible. But now \"git checkout branch\" behaves\n> quite differently in just deleting stuff that it doesn't own (i.e., is\n> untracked).\n> \n> Anyway, I'll rethink.\n\nFirst, did you consider just .gitignore'ing untracked files,\nand if they are compilation products use cc-cache instead?\n\nSecond, the way git treats untracked files is simple: do not\nlose information.  If a file is tracked, or to be more exact\nspecific contents of a file is in repository, then deleting\nit would not remove information.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"113196","messageId":"200905071117.00162.trast@student.ethz.ch","threadId":"19193","inReplyTo":"93c3eada0905070058g7f619a56jfb9b49f02bb92f9b@mail.gmail.com","subject":"Re: Tracking the untracked","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-05-07T09:16:56Z","receivedAt":"2009-05-07T09:16:56Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Geoff Russell wrote:\n>\n\nPlease keep the Cc list, it's customary around here and helps us find\nthe mails addressed to us.\n\n> On 5/6/09, Thomas Rast <trast@student.ethz.ch> wrote:\n> >  Your build products became tracked (w.r.t. the then-state of the\n> >  repository, on branch B1) the second you added them to the index with\n> >  'git add'.  Git then cares about them, and among many other things\n> >  will look at them whenever you change branches.  Since they're not\n> >  present in the target branch 'master', they are removed from the work\n> >  tree.\n[...]\n> Ok, its clearly a policy choice.  But suppose I have an untracked\n> file and I do \"git some-command\" then I don't expect git to touch what\n> it doesn't know about. I.e., \"git add x\" shouldn't delete the untracked\n> file y. That seems sensible. But now \"git checkout branch\" behaves\n> quite differently in just deleting stuff that it doesn't own (i.e., is\n> untracked).\n> \n> Anyway, I'll rethink.\n\nThey weren't untracked!\n\nThis is roughly what Dscho said, but I'll try to explain it in more\ndetail:\n\n- In the first step, when switching from master to B1, your build\n  products were indeed untracked (not part of either master or B1 or\n  the index).  So Git leaves them alone.\n\n- By adding (git add $file) your files to the index, you made them\n  tracked.[1]\n\n- By making a commit, you let the files \"officially\" belong to the\n  current branch (B1).  So with respect to the _current_ branch B1,\n  they _were_ tracked.\n\n- When you switch branches in the last step, Git sees that B1 has\n  these files, but master doesn't, so it removes them to bring the\n  worktree into the state that master has.\n\n- Consider what happens if you were to recompile at this point, so\n  that you again have the _untracked_ (w.r.t. the 'master' branch)\n  build products, and then check out B1 again.  Git faces the choice\n  of either overwriting your worktree files (and losing them) or not\n  overwriting (and not doing the checkout right), so it will abort.\n  This is a corollary of what Jakub pointed out, Git will not lose\n  information unless told to.\n\n\n[1] If you were to switch branches at this point, without making a\ncommit, Git tries to \"carry over\" the addition of files to the target\nbranch, unless it conflicts with files in that target branch, so the\nindex is in a slightly different position than the HEAD.  Still,\nanything that is listed in the index is considered tracked.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"113202","messageId":"93c3eada0905070354v2b8ff258m8db7b1d4968eb2ce@mail.gmail.com","threadId":"19193","inReplyTo":"200905071117.00162.trast@student.ethz.ch","subject":"Re: Tracking the untracked","fromName":"Geoff Russell","fromEmail":"geoffrey.russell@gmail.com","sentAt":"2009-05-07T10:54:30Z","receivedAt":"2009-05-07T10:54:30Z","isPatch":false,"sender":{"key":"geoffrey.russell@gmail.com","avatar":"https://gravatar.com/avatar/c30f497ccfa6bf06d86f30bd2ba092a2dd124c61c6bc902f7cb5c3f6486947de?d=mp&s=160"},"body":"On 5/7/09, Thomas Rast <trast@student.ethz.ch> wrote:\n> Geoff Russell wrote:\n> [...]\n>  - Consider what happens if you were to recompile at this point, so\n>   that you again have the _untracked_ (w.r.t. the 'master' branch)\n>   build products, and then check out B1 again.  Git faces the choice\n>   of either overwriting your worktree files (and losing them) or not\n>   overwriting (and not doing the checkout right), so it will abort.\n>   This is a corollary of what Jakub pointed out, Git will not lose\n>   information unless told to.\n\nUnderstood. Upon reflection, I can't think of a better alternative.\n\nCheers and thanks for the help,\n\nGeoff.\n"}]}