{"thread":{"id":"21892","subject":"[PATCH 2/2] git-rm doc: Describe how to sync index & work tree","startedAt":"2009-12-07T18:35:42Z","lastAt":"2009-12-08T06:19:03Z","messageCount":4,"participants":["Björn Gustavsson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"129438","messageId":"4B1D4AFE.6090708@gmail.com","threadId":"21892","inReplyTo":null,"subject":"[PATCH 2/2] git-rm doc: Describe how to sync index & work tree","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2009-12-07T18:35:42Z","receivedAt":"2009-12-07T18:35:42Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"Newcomers to git that want to remove from the index only the\nfiles that have disappeared from the working tree will probably\nlook for a way to do that in the documentation for 'git rm'.\n\nTherefore, describe how that can be done (even though it involves\nother commands than 'git rm'). Based on a suggestion by Junio,\nbut re-arranged and rewritten to better fit into the style of\ncommand reference.\n\nWhile at it, change a single occurrence of \"work tree\" to \"working\ntree\" for consistency.\n\nSigned-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n---\nTo better fit a reference page (IMO), I have changed the\norder of the commands, and have put the straightforward\ncommand last as it is the least useful, and I have removed\nthe \"bad examples\" (using two commands instead of simply\n'git add -A'). I realize that those examples have their value,\ntoo, but since most people scan a reference page quickly\nto find what they'll need, it will just confuse them.\n\n Documentation/git-rm.txt |   53 +++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 52 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt\nindex d4162f6..c622972 100644\n--- a/Documentation/git-rm.txt\n+++ b/Documentation/git-rm.txt\n@@ -13,7 +13,7 @@ DESCRIPTION\n -----------\n Remove files from the index, or from the working tree and the index.\n `git rm` will not remove a file from just your working directory.\n-(There is no option to remove a file only from the work tree\n+(There is no option to remove a file only from the working tree\n and yet keep it in the index; use `/bin/rm` if you want to do that.)\n The files being removed have to be identical to the tip of the branch,\n and no updates to their contents can be staged in the index,\n@@ -81,6 +81,57 @@ two directories `d` and `d2`, there is a difference between\n using `git rm \\'d\\*\\'` and `git rm \\'d/\\*\\'`, as the former will\n also remove all of directory `d2`.\n \n+REMOVING FILES THAT HAVE DISAPPEARED FROM THE FILESYSTEM\n+--------------------------------------------------------\n+There is no option for `git rm` to remove from the index only\n+the paths that have disappeared from the filesystem. However,\n+depending on the use case, there are several ways that can be\n+done.\n+\n+Using \"git commit -a\"\n+~~~~~~~~~~~~~~~~~~~~~\n+If you intend that your next commit should record all modifications\n+of tracked files in the working tree and record all removals of\n+files that have been removed from the working tree with `rm`\n+(as opposed to `git rm`), use `git commit -a`, as it will\n+automatically notice and record all removals.\n+\n+Using \"git add -A\"\n+~~~~~~~~~~~~~~~~~~\n+When accepting a new code drop for a vendor branch, you probably\n+want to record both the removal of paths and additions of new paths\n+as well as modifications of existing paths.\n+\n+Typically you would first remove all tracked files from the working\n+tree using this command:\n+\n+----------------\n+git ls-files -z | xargs -0 rm -f\n+----------------\n+\n+and then \"untar\" the new code in the working tree. Alternately\n+you could \"rsync\" the changes into the working tree.\n+\n+After that, the easiest way to record all removals, additions, and\n+modifications in the working tree is:\n+\n+----------------\n+git add -A\n+----------------\n+\n+See linkgit:git-add[1].\n+\n+Other ways\n+~~~~~~~~~~\n+If all you really want to do is to remove from the index the files\n+that are no longer present in the working tree (perhaps because\n+your working tree is dirty so that you cannot use `git commit -a`),\n+use the following command:\n+\n+----------------\n+git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached\n+----------------\n+\n EXAMPLES\n --------\n git rm Documentation/\\\\*.txt::\n-- \n1.6.6.rc1.31.g1a56b\n"},{"id":"129451","messageId":"7vpr6qze4i.fsf@alter.siamese.dyndns.org","threadId":"21892","inReplyTo":"4B1D4AFE.6090708@gmail.com","subject":"Re: [PATCH 2/2] git-rm doc: Describe how to sync index & work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-07T21:08:13Z","receivedAt":"2009-12-07T21:08:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Looks sensible.\n\nI think mentioning \"add -u\" in the same section as \"commit -a\" would be\nhelpful, as these two are more for user's own development (as opposed to\nvendor-code-drop).  I'd perhaps squash something like this in.  Please say\n\"yes\", \"don't, it is horrible\", or something in between ;-)\n\n--\n Documentation/git-rm.txt |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt\nindex c622972..42161d7 100644\n--- a/Documentation/git-rm.txt\n+++ b/Documentation/git-rm.txt\n@@ -94,7 +94,8 @@ If you intend that your next commit should record all modifications\n of tracked files in the working tree and record all removals of\n files that have been removed from the working tree with `rm`\n (as opposed to `git rm`), use `git commit -a`, as it will\n-automatically notice and record all removals.\n+automatically notice and record all removals.  `git add -u`\n+can be used for a similar effect without commiting.\n \n Using \"git add -A\"\n ~~~~~~~~~~~~~~~~~~\n"},{"id":"129487","messageId":"6672d0160912072212j5b6f5c0bha57e818ccf975ba6@mail.gmail.com","threadId":"21892","inReplyTo":"7vpr6qze4i.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-rm doc: Describe how to sync index & work tree","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2009-12-08T06:12:57Z","receivedAt":"2009-12-08T06:12:57Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"2009/12/7 Junio C Hamano <gitster@pobox.com>:\n> Looks sensible.\n>\n> I think mentioning \"add -u\" in the same section as \"commit -a\" would be\n> helpful, as these two are more for user's own development (as opposed to\n> vendor-code-drop).  I'd perhaps squash something like this in.  Please say\n> \"yes\", \"don't, it is horrible\", or something in between ;-)\n\nYes. :-)\n\n-- \nBjörn Gustavsson, Erlang/OTP, Ericsson AB\n"},{"id":"129488","messageId":"6672d0160912072219g4326bb5pde7bd02c09a9556a@mail.gmail.com","threadId":"21892","inReplyTo":"7vpr6qze4i.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-rm doc: Describe how to sync index & work tree","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2009-12-08T06:19:03Z","receivedAt":"2009-12-08T06:19:03Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"2009/12/7 Junio C Hamano <gitster@pobox.com>:\n> I think mentioning \"add -u\" in the same section as \"commit -a\" would be\n> helpful, as these two are more for user's own development (as opposed to\n> vendor-code-drop).  I'd perhaps squash something like this in.  Please say\n> \"yes\", \"don't, it is horrible\", or something in between ;-)\n\nYes, but...\n\n> -automatically notice and record all removals.\n> +automatically notice and record all removals.  `git add -u`\n> +can be used for a similar effect without commiting.\n\ns/commiting/committing/\n\n-- \nBjörn Gustavsson, Erlang/OTP, Ericsson AB\n"}]}