{"thread":{"id":"13911","subject":"Deleting files","startedAt":"2008-06-12T11:28:30Z","lastAt":"2008-06-12T20:44:19Z","messageCount":6,"participants":["Shak","Pieter de Bie","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"79584","messageId":"g2r19e$s6e$1@ger.gmane.org","threadId":"13911","inReplyTo":null,"subject":"Deleting files","fromName":"Shak","fromEmail":"sshaikh@hotmail.com","sentAt":"2008-06-12T11:28:30Z","receivedAt":"2008-06-12T11:28:30Z","isPatch":false,"sender":{"key":"sshaikh@hotmail.com","avatar":null},"body":"Hi,\n\nAre files supposed to be continually tracked after commiting after deleting \nthem?\n\ngit status reports that files have been deleted as expected (they're not \nthere anymore). I commit as wanted. I do some more work, but then git status \nstill reports that the same files have been deleted. As such I have a \nhistorical list of \"deleted\" files that I may have been working on \npreviously and had committed.\n\nI have to run git rm to erase these entries, but I've no idea how that \naffects my history.\n\nShouldn't git add/commit remember that a file has been deleted previously?\n\nOn a related note, once I do git rm on one of these files, git status \nsometimes reports that these rm'd files have been renamed to a new one \ninstead! What's going on? :(\n\nShak \n"},{"id":"79585","messageId":"g2r1sb$tut$1@ger.gmane.org","threadId":"13911","inReplyTo":"g2r19e$s6e$1@ger.gmane.org","subject":"Re: Deleting files","fromName":"Shak","fromEmail":"sshaikh@hotmail.com","sentAt":"2008-06-12T11:38:37Z","receivedAt":"2008-06-12T11:38:37Z","isPatch":false,"sender":{"key":"sshaikh@hotmail.com","avatar":null},"body":"\"Shak\" <sshaikh@hotmail.com> wrote in message \nnews:g2r19e$s6e$1@ger.gmane.org...\n> Hi,\n>\n> Are files supposed to be continually tracked after commiting after \n> deleting them?\n>\n> git status reports that files have been deleted as expected (they're not \n> there anymore). I commit as wanted. I do some more work, but then git \n> status still reports that the same files have been deleted. As such I have \n> a historical list of \"deleted\" files that I may have been working on \n> previously and had committed.\n>\n> I have to run git rm to erase these entries, but I've no idea how that \n> affects my history.\n>\n> Shouldn't git add/commit remember that a file has been deleted previously?\n>\n> On a related note, once I do git rm on one of these files, git status \n> sometimes reports that these rm'd files have been renamed to a new one \n> instead! What's going on? :(\n\nTo be clear on the last point, git seems to be incorrectly detecting that \nI've copied (sometimes to the same directory) and renamed files. What's the \ndifference anyway? And is there anyway to override it's overzelaous \nassumptions?\n\nShak \n"},{"id":"79588","messageId":"g2r36d$2ju$1@ger.gmane.org","threadId":"13911","inReplyTo":"g2r1sb$tut$1@ger.gmane.org","subject":"Re: Deleting files","fromName":"Shak","fromEmail":"sshaikh@hotmail.com","sentAt":"2008-06-12T12:01:01Z","receivedAt":"2008-06-12T12:01:01Z","isPatch":false,"sender":{"key":"sshaikh@hotmail.com","avatar":null},"body":"\"Shak\" <sshaikh@hotmail.com> wrote in message \nnews:g2r1sb$tut$1@ger.gmane.org...\n> \"Shak\" <sshaikh@hotmail.com> wrote in message \n> news:g2r19e$s6e$1@ger.gmane.org...\n>> Hi,\n>>\n>> Are files supposed to be continually tracked after commiting after \n>> deleting them?\n>>\n>> git status reports that files have been deleted as expected (they're not \n>> there anymore). I commit as wanted. I do some more work, but then git \n>> status still reports that the same files have been deleted. As such I \n>> have a historical list of \"deleted\" files that I may have been working on \n>> previously and had committed.\n>>\n>> I have to run git rm to erase these entries, but I've no idea how that \n>> affects my history.\n>>\n>> Shouldn't git add/commit remember that a file has been deleted \n>> previously?\n>>\n>> On a related note, once I do git rm on one of these files, git status \n>> sometimes reports that these rm'd files have been renamed to a new one \n>> instead! What's going on? :(\n>\n> To be clear on the last point, git seems to be incorrectly detecting that \n> I've copied (sometimes to the same directory) and renamed files. What's \n> the difference anyway? And is there anyway to override it's overzelaous \n> assumptions?\n>\n\nTo rudely reply to my own message a second time, it seems I have to \nexplicitly run \"git add -u\" to actually commit deletions before committing. \nI don't notice any changes in \"git status\" so there doesn't seem a way of \nknowing that it's required.\n\nI've also noticed that renames aren't detected until you commit a delete.\n\nThis is all becoming very counter-intuitive :(\n\nShak \n"},{"id":"79590","messageId":"477B22F6-9F24-4CBE-98EE-58EF697E6320@ai.rug.nl","threadId":"13911","inReplyTo":"g2r36d$2ju$1@ger.gmane.org","subject":"Re: Deleting files","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-06-12T12:11:25Z","receivedAt":"2008-06-12T12:11:25Z","isPatch":false,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"\nOn 12 jun 2008, at 14:01, Shak wrote:\n\n> This is all becoming very counter-intuitive :(\n\nIt seems you are missing the concept of the index. Let's look\nat an example:\nVienna:a pieter$ git init\nInitialized empty Git repository in /Users/pieter/a/.git/\nVienna:a pieter$ touch a b\nVienna:a pieter$ git commit -m \"Initial commit\"\nCreated initial commit f0a0fe2: Initial commit\n  0 files changed, 0 insertions(+), 0 deletions(-)\n  create mode 100644 a\n  create mode 100644 b\nVienna:a pieter$ rm a\nVienna:a pieter$ git status\n# On branch master\n# Changed but not updated:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#\n#       deleted:    a\n#\n\nThis is the point where you were. Look at the line \"Changed but no  \nupdated\"\nand also the hint \"(use \"git add/rm <file>...\" to update what will be  \ncommitted)\".\n\nVienna:a pieter$ echo \"text\" >b && git add b && git commit -m \"change\"\nCreated commit e28a131: change\n  1 files changed, 1 insertions(+), 0 deletions(-)\n\nYou changed b and commited it, but did nothing with a. now when you do  \ngit status:\n\nVienna:a pieter$ git status\n# On branch master\n# Changed but not updated:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#\n#       deleted:    a\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nIt'll still show it as deleted. And still gives you a hint on what to do\n(TWICE!). So, let's do that:\n\nVienna:a pieter$ git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       deleted:    a\n#\n\n\nNotice that it now says \"Changes to be committed\"! If you commit now,  \nyour\nstatus will be clean:\n\nVienna:a pieter$ git commit -m \"deleted a\"\nCreated commit 02bbe7b: deleted a\n  0 files changed, 0 insertions(+), 0 deletions(-)\n  delete mode 100644 a\nVienna:a pieter$ git status\n# On branch master\nnothing to commit (working directory clean)\n\n\nIn short, the point is that you never commited the deletions! Your  \nwhole history\nuntil now will still show those deleted files. You can commit the  \nactually deletions\nnow, as you should have done before (either by using \"git rm <file>\",  \n\"git add -u\",\n\"git commit -a\" or \"git commit <file>\".\n\n- Pieter\n"},{"id":"79593","messageId":"g2r4ha$74i$1@ger.gmane.org","threadId":"13911","inReplyTo":"477B22F6-9F24-4CBE-98EE-58EF697E6320@ai.rug.nl","subject":"Re: Deleting files","fromName":"Shak","fromEmail":"sshaikh@hotmail.com","sentAt":"2008-06-12T12:23:53Z","receivedAt":"2008-06-12T12:23:53Z","isPatch":false,"sender":{"key":"sshaikh@hotmail.com","avatar":null},"body":"\"Pieter de Bie\" <pdebie@ai.rug.nl> wrote in message \nnews:477B22F6-9F24-4CBE-98EE-58EF697E6320@ai.rug.nl...\n>\n> In short, the point is that you never commited the deletions! Your  whole \n> history\n> until now will still show those deleted files. You can commit the \n> actually deletions\n> now, as you should have done before (either by using \"git rm <file>\", \n> \"git add -u\",\n> \"git commit -a\" or \"git commit <file>\".\n>\n\nThanks for the quick workflow. To fill in a gap in my OP, I was using \"git \nadd .\" to add new files before a \"commit\". Since I (perhaps incorrectly) \ntook \"commit -a\" as a short cut for these two commands, I assumed that \"git \nadd .\" would also commit deletions.\n\nSo sticking to my previous workflow (I need to do this since \"commit -a\" as \nI understand it doesn't commit new files, and I often forget that I've added \n:)), it seems I should do the following to keep the working directory in \nsync with the repository:\n\ngit add .\ngit add -u\ngit commit\n\nIs that right? Should the two add commands be called in that order or \ndoesn't it matter?\n\nI ask because I'm still concerned with how git assumed I had renamed files \nafter I had \"git rm\"d them. As far as I could tell they were not very alike. \nPerhaps adding the new files before removing the old ones would stop this \nbehavior?\n\nShak \n"},{"id":"79632","messageId":"20080612204419.GA22787@steel.home","threadId":"13911","inReplyTo":"g2r4ha$74i$1@ger.gmane.org","subject":"Re: Deleting files","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-06-12T20:44:19Z","receivedAt":"2008-06-12T20:44:19Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Shak, Thu, Jun 12, 2008 14:23:53 +0200:\n> \"Pieter de Bie\" <pdebie@ai.rug.nl> wrote in message  \n> news:477B22F6-9F24-4CBE-98EE-58EF697E6320@ai.rug.nl...\n>>\n>> In short, the point is that you never commited the deletions! Your  \n>> whole history\n>> until now will still show those deleted files. You can commit the  \n>> actually deletions\n>> now, as you should have done before (either by using \"git rm <file>\",  \n>> \"git add -u\",\n>> \"git commit -a\" or \"git commit <file>\".\n>>\n>\n> Thanks for the quick workflow. To fill in a gap in my OP, I was using \n> \"git add .\" to add new files before a \"commit\". Since I (perhaps \n> incorrectly) took \"commit -a\" as a short cut for these two commands, I \n> assumed that \"git add .\" would also commit deletions.\n\n\"git add\" just adds, unless told to update (with -u). And \"git commit -a\"\njust updates and commits. Updates include forgetting removed files,\nbut not adding new (thats on purpose: too many of us have random files\nin our working trees).\n\n> So sticking to my previous workflow (I need to do this since \"commit -a\" \n> as I understand it doesn't commit new files, and I often forget that I've \n> added :)), it seems I should do the following to keep the working \n> directory in sync with the repository:\n>\n> git add .\n\nthis will add everthing which isn't ignored (in .git/info/exclude or\n.gitignore's). Are you sure you want that generated and backup files\nin your history? Maybe your workflow could use \"git add new-file-1\nnew-file-2...\"?\n\n> git add -u\n> git commit\n>\n> Is that right? Should the two add commands be called in that order or  \n> doesn't it matter?\n\neither \"git add . && git commit -a\" or \"git add . && git add -u && git\ncommit\".\n\n> I ask because I'm still concerned with how git assumed I had renamed \n> files after I had \"git rm\"d them. As far as I could tell they were not \n> very alike. Perhaps adding the new files before removing the old ones \n> would stop this behavior?\n\nWhy should you care? They seem to be similar enough, but besides the\nlisting, there is nothing which relates them in the git structures.\nHappens often for small files.\n\nJust adopt \"git commit -a\" and ignore that.\n"}]}