{"thread":{"id":"36701","subject":"Any difference to unstage files using \"git checkout\" and \"git rm\"","startedAt":"2014-05-19T14:42:47Z","lastAt":"2014-05-19T16:45:27Z","messageCount":5,"participants":["Arup Rakshit","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"242171","messageId":"6833494.47nikG189t@linux-wzza.site","threadId":"36701","inReplyTo":null,"subject":"Any difference to unstage files using \"git checkout\" and \"git rm\"","fromName":"Arup Rakshit","fromEmail":"aruprakshit@rocketmail.com","sentAt":"2014-05-19T14:42:47Z","receivedAt":"2014-05-19T14:42:47Z","isPatch":false,"sender":{"key":"aruprakshit@rocketmail.com","avatar":"https://gravatar.com/avatar/a05a6142b0941fafb88c96b156982deb8e49e863ae7803d15c5147276fdeff92?d=mp&s=160"},"body":"Hi,\n\nIs there any difference between the below 2 commands ? I didn't see anything.\n\ngit rm --cached  -- <file1> .. <fileN>\ngit checkout  -- <file1> .. <fileN>\n\n\n-- \n===============\nRegards,\nArup Rakshit\n"},{"id":"242175","messageId":"2484900.5bGOI3HfEm@linux-wzza.site","threadId":"36701","inReplyTo":"6833494.47nikG189t@linux-wzza.site","subject":"Re: Any difference to unstage files using \"git checkout\" and \"git rm\"","fromName":"Arup Rakshit","fromEmail":"aruprakshit@rocketmail.com","sentAt":"2014-05-19T14:57:47Z","receivedAt":"2014-05-19T14:57:47Z","isPatch":false,"sender":{"key":"aruprakshit@rocketmail.com","avatar":"https://gravatar.com/avatar/a05a6142b0941fafb88c96b156982deb8e49e863ae7803d15c5147276fdeff92?d=mp&s=160"},"body":"On Monday, May 19, 2014 09:12:47 PM you wrote:\n> Hi,\n> \n> Is there any difference between the below 2 commands ? I didn't see\n> anything.\n> \n> git rm --cached  -- <file1> .. <fileN>\n> git checkout  -- <file1> .. <fileN>\n\nPlease Ignore the previous.\n\nI apologize to rewriting and increase the load of this mailing list. I \nactually wanted to ask the below \n\ngit rm -- cached  -- <file1> .. <fileN>\ngit reset HEAD  <file1> .. <fileN>﻿\n\n-- \n===============\nRegards,\nArup Rakshit\n"},{"id":"242174","messageId":"20140519160107.GE20289@sigill.intra.peff.net","threadId":"36701","inReplyTo":"6833494.47nikG189t@linux-wzza.site","subject":"Re: Any difference to unstage files using \"git checkout\" and \"git rm\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-05-19T16:01:07Z","receivedAt":"2014-05-19T16:01:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 19, 2014 at 09:12:47PM +0630, Arup Rakshit wrote:\n\n> Is there any difference between the below 2 commands ? I didn't see anything.\n> \n> git rm --cached  -- <file1> .. <fileN>\n\nThis one removes the index entries for those files.\n\n> git checkout  -- <file1> .. <fileN>\n\nThis one checks out the content from the index into the working tree\n(for just those files).\n\nTry:\n\n  # setup...\n  git init\n  echo content >file\n  git add file\n  git commit -m one\n\n  # now rm\n  git rm --cached -- file\n  git status\n\nwhich yields:\n\n  rm 'file'\n\n  On branch master\n  Changes to be committed:\n          deleted:    file\n  \n  Untracked files:\n          file\n  \n\nbut it we restore our state and try checkout:\n\n  git reset\n  git checkout -- file\n\nnothing happens:\n\n  On branch master\n  nothing to commit, working directory clean\n\nbut if you had changes in the working tree:\n\n  echo changes >file\n  git status | sed 's/^/before> /'\n  git checkout -- file\n  git status | sed 's/^/ after> /'\n\nyou get:\n\n  before> On branch master\n  before> Changes not staged for commit:\n  before>         modified:   file\n  before> \n  before> no changes added to commit\n\n   after> On branch master\n   after> nothing to commit, working directory clean\n\nDoes that help?\n\n-Peff\n"},{"id":"242183","messageId":"2609761.VA4bvU75e5@linux-wzza.site","threadId":"36701","inReplyTo":"20140519160107.GE20289@sigill.intra.peff.net","subject":"Re: Any difference to unstage files using \"git checkout\" and \"git rm\"","fromName":"Arup Rakshit","fromEmail":"aruprakshit@rocketmail.com","sentAt":"2014-05-19T16:11:42Z","receivedAt":"2014-05-19T16:11:42Z","isPatch":false,"sender":{"key":"aruprakshit@rocketmail.com","avatar":"https://gravatar.com/avatar/a05a6142b0941fafb88c96b156982deb8e49e863ae7803d15c5147276fdeff92?d=mp&s=160"},"body":"On Monday, May 19, 2014 12:01:07 PM you wrote:\n> On Mon, May 19, 2014 at 09:12:47PM +0630, Arup Rakshit wrote:\n> > Is there any difference between the below 2 commands ? I didn't see\n> > anything.\n> > \n\n> \n> Does that help?\n\nFor me who is in Git just 6-7 days, It is huge. On your way, I was walking to \ntest those out. But I got some messages from Git, which made me confused to \nthink, about the *philosophy of those*.\n\narup@linux-wzza:~> mkdir Git_tutorial\narup@linux-wzza:~> cd Git_tutorial/\narup@linux-wzza:~/Git_tutorial> LS\nIf 'LS' is not a typo you can use command-not-found to lookup the package that \ncontains it, like this:\n    cnf LS\narup@linux-wzza:~/Git_tutorial> ls\narup@linux-wzza:~/Git_tutorial> echo \"welcome to git\" > test.txt\narup@linux-wzza:~/Git_tutorial> ls\ntest.txt\narup@linux-wzza:~/Git_tutorial> git init\nInitialized empty Git repository in /home/arup/Git_tutorial/.git/\narup@linux-wzza:~/Git_tutorial> git status\n# On branch master\n#\n# Initial commit\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       test.txt\nnothing added to commit but untracked files present (use \"git add\" to track)\narup@linux-wzza:~/Git_tutorial> git add test.txt\narup@linux-wzza:~/Git_tutorial> git status\n# On branch master\n#\n# Initial commit\n#\n# Changes to be committed:\n#   (use \"git rm --cached <file>...\" to unstage)\n#\n#       new file:   test.txt\n#\n\nNOTE :- While, I have a new file in my repository, and I staged it, it is \ntelling me to unstage it using *git rm -- cached <file>*. But once I committed, \nand the file became a tracked file in my repository, *Git* internal message got \nchanged, *for unstaging*, Which is why, I asked this question. Look below -\n\narup@linux-wzza:~/Git_tutorial> git commit -m \"commit1\"\n[master (root-commit) 20bf27f] commit1\n 1 file changed, 1 insertion(+)\n create mode 100644 test.txt\narup@linux-wzza:~/Git_tutorial> echo \"How are you enjoying?\" > test.txt\narup@linux-wzza:~/Git_tutorial> git status\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#       modified:   test.txt\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\narup@linux-wzza:~/Git_tutorial> git add test.txt\narup@linux-wzza:~/Git_tutorial> git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       modified:   test.txt\n#\narup@linux-wzza:~/Git_tutorial>\n\nIt is now telling to USE \"git reset HEAD <file>...\" to unstage, NOT   \"git rm \n--cached <file>...\" to unstage.\n\nPlease let me know, If I am making you guys more confused.\n\n-- \n===============\nRegards,\nArup Rakshit\n"},{"id":"242178","messageId":"20140519164526.GA27176@sigill.intra.peff.net","threadId":"36701","inReplyTo":"2484900.5bGOI3HfEm@linux-wzza.site","subject":"Re: Any difference to unstage files using \"git checkout\" and \"git rm\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-05-19T16:45:27Z","receivedAt":"2014-05-19T16:45:27Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 19, 2014 at 09:27:47PM +0630, Arup Rakshit wrote:\n\n> > Is there any difference between the below 2 commands ? I didn't see\n> > anything.\n> > \n> > git rm --cached  -- <file1> .. <fileN>\n> > git checkout  -- <file1> .. <fileN>\n> \n> Please Ignore the previous.\n\nToo late. :)\n\n> I apologize to rewriting and increase the load of this mailing list. I \n> actually wanted to ask the below \n> \n> git rm -- cached  -- <file1> .. <fileN>\n> git reset HEAD  <file1> .. <fileN>﻿\n\nOK, this is a more sensible comparison.\n\nThe first command will remove the entries from the index entirely, and\nthe second one will return them to their state in HEAD. So _if_ the\nexisting commit in HEAD did not have the files at all, the two are\nidentical.\n\nBut if the files were committed previously, then the second command will\nreturn them to that state, not remove them entirely.\n\nDoes that make sense?\n\n-Peff\n"}]}