{"thread":{"id":"13629","subject":"Deleted files can't be checked back out?","startedAt":"2008-05-23T04:28:57Z","lastAt":"2008-05-25T23:37:27Z","messageCount":4,"participants":["fREW","Chris Frey","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"77520","messageId":"fb3648c60805222128v1a425c60kc8e44f3a2fb41d54@mail.gmail.com","threadId":"13629","inReplyTo":null,"subject":"Deleted files can't be checked back out?","fromName":"fREW","fromEmail":"frioux@gmail.com","sentAt":"2008-05-23T04:28:57Z","receivedAt":"2008-05-23T04:28:57Z","isPatch":false,"sender":{"key":"frioux@gmail.com","avatar":"https://gravatar.com/avatar/639ef3cc221c7f2c225568697bc9d42be4d4e3bada6b4a3b9c32685548f3c105?d=mp&s=160"},"body":"Hello all,\n\nI recently deleted a bunch of files and checked the change into git,\nand then changed my mind and wanted the files back.  I did a\ngit-checkout <file> and got each file back individually.  Then I did\nsome work and did a git-push to upload to github. Then I did more work\nand tried to do a git push and it gave me an error that apparently\nmeant I had to pull before I pushed.  Anyway, I pulled, it redeleted\nthe files and now when I do git-checkout <file> to get them back it\nsays:\n\nerror: pathspec 'foo' did not match any file(s) known to git.\n\nI'd really appreciate some help on this issue. I tried messing with\nqgit to look at it, but I didn't have much luck...\n\n-fREW\n"},{"id":"77527","messageId":"20080523062821.GA24411@foursquare.net","threadId":"13629","inReplyTo":"fb3648c60805222128v1a425c60kc8e44f3a2fb41d54@mail.gmail.com","subject":"Re: Deleted files can't be checked back out?","fromName":"Chris Frey","fromEmail":"cdfrey@foursquare.net","sentAt":"2008-05-23T06:28:21Z","receivedAt":"2008-05-23T06:28:21Z","isPatch":false,"sender":{"key":"cdfrey@foursquare.net","avatar":null},"body":"On Thu, May 22, 2008 at 11:28:57PM -0500, fREW wrote:\n> I recently deleted a bunch of files and checked the change into git,\n> and then changed my mind and wanted the files back.  I did a\n> git-checkout <file> and got each file back individually.  Then I did\n\nI believe you want to undo the change you made (deleting files), not\njust view an old version of the file, which is what checkout does.\n\nYou can either add it back yourself, or you can undo the last commit, using\ngit-reset.\n\nHere's an example of what you could have done before making further\nchanges that you wanted to push:\n\n\tgit rm file\n\tgit commit\n\tgit log\t\t\t# view your change\n\tgit reset --hard HEAD^\t# go back to the HEAD before your change\n\nThink of the chain of commits as a long linked list of changes.  A branch\nhead is just a pointer to the top of that linked list.  git-reset allows\nyou to point that HEAD to anywhere in the list, even after going back\nin history.  The commits are still there, even if HEAD doesn't explicitly\npoint to them.\n\nFor example, say git log shows commit 1a2b3c4 as HEAD, with commit 7abc983\nas its parent.  You can move the HEAD back and forth, like this:\n\n\tgit reset --hard 7abc983\n\tgit log\t\t\t# commit 1a2b3c4 is gone!\n\tgit reset --hard 1a2b3c4\n\tgit log\t\t\t# now it's back!\n\nBut in your case, you now have a list of commits that is missing files:\n\n        A -> B -> C\n             |    |\n             |    (made changes here)\n             |\n             (deleted files here)\n\nSo in this case you likely want to revert commit B, while keeping commit C.\n\n\tgit log\t\t\t# get the commit SHA1, let's say it's 04bcb93\n\tgit revert 04bcb93\n\n\nTake a look at \"Git from the bottom up\"\n\thttp://www.newartisans.com/blog_files/git.from.bottom.up.php\n\n- Chris\n"},{"id":"77625","messageId":"m38wy04jo1.fsf@localhost.localdomain","threadId":"13629","inReplyTo":"fb3648c60805222128v1a425c60kc8e44f3a2fb41d54@mail.gmail.com","subject":"Re: Deleted files can't be checked back out?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-05-24T00:43:05Z","receivedAt":"2008-05-24T00:43:05Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"fREW <frioux@gmail.com> writes:\n\n> I recently deleted a bunch of files and checked the change into git,\n> and then changed my mind and wanted the files back.  I did a\n> git-checkout <file> and got each file back individually.  Then I did\n> some work and did a git-push to upload to github. Then I did more work\n> and tried to do a git push and it gave me an error that apparently\n> meant I had to pull before I pushed.  \n\nYou didn't change history, did you (e.g. using rebase)?\n\n> Anyway, I pulled, it redeleted the files and now when I do\n> git-checkout <file> to get them back it says:\n> \n> error: pathspec 'foo' did not match any file(s) known to git.\n\nUse \"git checkout -- <file>\" (or \"git checkout HEAD -- <file>\") to do\na checkout of a file which is not present in the working area.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"77725","messageId":"fb3648c60805251637p70bc76fdm1947da6b9bf34ca1@mail.gmail.com","threadId":"13629","inReplyTo":"20080523062821.GA24411@foursquare.net","subject":"Re: Deleted files can't be checked back out?","fromName":"fREW","fromEmail":"frioux@gmail.com","sentAt":"2008-05-25T23:37:27Z","receivedAt":"2008-05-25T23:37:27Z","isPatch":false,"sender":{"key":"frioux@gmail.com","avatar":"https://gravatar.com/avatar/639ef3cc221c7f2c225568697bc9d42be4d4e3bada6b4a3b9c32685548f3c105?d=mp&s=160"},"body":"Just FYI, git revert was exactly what I needed.  If you want to undo\nany commit at all git revert is your friend.\n\nThanks!\n\n-fREW\n\nOn 5/23/08, Chris Frey <cdfrey@foursquare.net> wrote:\n> On Thu, May 22, 2008 at 11:28:57PM -0500, fREW wrote:\n>> I recently deleted a bunch of files and checked the change into git,\n>> and then changed my mind and wanted the files back.  I did a\n>> git-checkout <file> and got each file back individually.  Then I did\n>\n> I believe you want to undo the change you made (deleting files), not\n> just view an old version of the file, which is what checkout does.\n>\n> You can either add it back yourself, or you can undo the last commit, using\n> git-reset.\n>\n> Here's an example of what you could have done before making further\n> changes that you wanted to push:\n>\n> \tgit rm file\n> \tgit commit\n> \tgit log\t\t\t# view your change\n> \tgit reset --hard HEAD^\t# go back to the HEAD before your change\n>\n> Think of the chain of commits as a long linked list of changes.  A branch\n> head is just a pointer to the top of that linked list.  git-reset allows\n> you to point that HEAD to anywhere in the list, even after going back\n> in history.  The commits are still there, even if HEAD doesn't explicitly\n> point to them.\n>\n> For example, say git log shows commit 1a2b3c4 as HEAD, with commit 7abc983\n> as its parent.  You can move the HEAD back and forth, like this:\n>\n> \tgit reset --hard 7abc983\n> \tgit log\t\t\t# commit 1a2b3c4 is gone!\n> \tgit reset --hard 1a2b3c4\n> \tgit log\t\t\t# now it's back!\n>\n> But in your case, you now have a list of commits that is missing files:\n>\n>         A -> B -> C\n>              |    |\n>              |    (made changes here)\n>              |\n>              (deleted files here)\n>\n> So in this case you likely want to revert commit B, while keeping commit C.\n>\n> \tgit log\t\t\t# get the commit SHA1, let's say it's 04bcb93\n> \tgit revert 04bcb93\n>\n>\n> Take a look at \"Git from the bottom up\"\n> \thttp://www.newartisans.com/blog_files/git.from.bottom.up.php\n>\n> - Chris\n>\n>\n"}]}