{"thread":{"id":"34603","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","startedAt":"2013-08-03T12:01:30Z","lastAt":"2013-08-10T07:33:43Z","messageCount":7,"participants":["Adam A","Daniel Convissor","Jonathan Nieder","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"224520","messageId":"CAJOTJ-Cgdg4CQs-3t1CsBkq_feVEpkoASzQSTATiVugjs+LL7w@mail.gmail.com","threadId":"34603","inReplyTo":"CAJOTJ-AVamimToPo4oQ=O_Pg+mJHQhardO+NfU8b1dvRxg1KMA@mail.gmail.com","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Adam A","fromEmail":"hitsthings@gmail.com","sentAt":"2013-08-03T12:01:30Z","receivedAt":"2013-08-03T12:01:30Z","isPatch":false,"sender":{"key":"hitsthings@gmail.com","avatar":null},"body":"Hello, the project readme on github points here for submitting bug\nreports, but please let me know if I'm in the wrong place.\n\nSteps to reproduce:\n\n- create a remote repository at URL with commit(s) in it\n  - e.g., a new github repo with README and LICENSE files auto-added\n- write some files in a local directory\n- git init\n- git add .\n  - the contents of the directory are now in the index\n- git remote add origin URL\n- git pull origin master\n\nThe local files added to the index are now completely wiped out and\nreplaced with the remote content. I lose all my previous work. :/\n\nThis was pretty painful for me to lose a few days of work. I also\ncouldn't stash my changes which I tried first, but git refused without\nan initial commit.\n\nWould have been nice if git warning me about the destructive operation.\n\nCheers,\nAdam\n\nOn Sat, Aug 3, 2013 at 9:57 PM, Adam A <hitsthings@gmail.com> wrote:\n> Hello, the project readme on github points here for submitting bug reports,\n> but please let me know if I'm in the wrong place.\n>\n> Steps to reproduce:\n>\n> - create a remote repository at URL with commit(s) in it\n>   - e.g., a new github repo with README and LICENSE files auto-added\n> - write some files in a local directory\n> - git init\n> - git add .\n>   - the contents of the directory are now in the index\n> - git remote add origin URL\n> - git pull origin master\n>\n> The local files added to the index are now completely wiped out and replaced\n> with the remote content. I lose all my previous work. :/\n>\n> This was pretty painful for me to lose a few days of work. I also couldn't\n> stash my changes which I tried first, but git refused without an initial\n> commit.\n>\n> Would have been nice if git warning me about the destructive operation.\n>\n> Cheers,\n> Adam\n"},{"id":"224528","messageId":"20130803163915.GB945@analysisandsolutions.com","threadId":"34603","inReplyTo":"CAJOTJ-Cgdg4CQs-3t1CsBkq_feVEpkoASzQSTATiVugjs+LL7w@mail.gmail.com","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Daniel Convissor","fromEmail":"danielc@analysisandsolutions.com","sentAt":"2013-08-03T16:39:15Z","receivedAt":"2013-08-03T16:39:15Z","isPatch":false,"sender":{"key":"danielc@analysisandsolutions.com","avatar":"https://gravatar.com/avatar/6934d176616faccef0fe2329329c24e2a2d92783d565704c7c4f85ea9219d412?d=mp&s=160"},"body":"Hi Adam:\n\nOn Sat, Aug 03, 2013 at 10:01:30PM +1000, Adam A wrote:\n> - create a remote repository at URL with commit(s) in it\n>   - e.g., a new github repo with README and LICENSE files auto-added\n> - write some files in a local directory\n> - git init\n> - git add .\n>   - the contents of the directory are now in the index\n> - git remote add origin URL\n> - git pull origin master\n> \n> The local files added to the index are now completely wiped out and\n> replaced with the remote content. I lose all my previous work. :/\n\nAll is not lost.  Your local files should be stored in the repository's\nreflog.  Examine the output of \"git reflog\".  You can then reset your\nworking directory to obtain those files by doing something _like_\n\"git reset --hard HEAD@{1}\".\n\nAll hail reflog.\n\nGood luck,\n\n--Dan\n\n-- \n T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y\n            data intensive web and database programming\n                http://www.AnalysisAndSolutions.com/\n        4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335\n"},{"id":"224531","messageId":"20130803165728.GB2893@elie.Belkin","threadId":"34603","inReplyTo":"20130803163915.GB945@analysisandsolutions.com","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-08-03T16:57:28Z","receivedAt":"2013-08-03T16:57:28Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Daniel Convissor wrote:\n\n> All is not lost.  Your local files should be stored in the repository's\n> reflog.  Examine the output of \"git reflog\".  You can then reset your\n> working directory to obtain those files by doing something _like_\n> \"git reset --hard HEAD@{1}\".\n\nAdam hadn't made a commit, so that wouldn't work in this case.\n\n\"git fsck --lost-found\" should be helpful, but yeah, this is a bug.\nSee for example [1] for the start of a patch to play with (needs\ntests).\n\nThanks and hope that helps,\nJonathan\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/196502/focus=196503\n"},{"id":"224532","messageId":"20130803165923.GD945@analysisandsolutions.com","threadId":"34603","inReplyTo":"20130803163915.GB945@analysisandsolutions.com","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Daniel Convissor","fromEmail":"danielc@analysisandsolutions.com","sentAt":"2013-08-03T16:59:23Z","receivedAt":"2013-08-03T16:59:23Z","isPatch":false,"sender":{"key":"danielc@analysisandsolutions.com","avatar":"https://gravatar.com/avatar/6934d176616faccef0fe2329329c24e2a2d92783d565704c7c4f85ea9219d412?d=mp&s=160"},"body":"Hey Again Adam:\n\nOn Sat, Aug 03, 2013 at 12:39:15PM -0400, Daniel Convissor wrote:\n> \n> All is not lost.  Your local files should be stored in the repository's\n> reflog.  Examine the output of \"git reflog\".  You can then reset your\n> working directory to obtain those files by doing something _like_\n> \"git reset --hard HEAD@{1}\".\n\nA further thought.  The most useful thing to do would probably be along\nthese lines...\n\ngit reflog  # as mentioned before\ngit checkout -b myinitialstuff HEAD@{<desired number>}\ngit log\ngit checkout master\ngit cherry-pick <hash of your first local commit>\n\n--Dan\n\n-- \n T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y\n            data intensive web and database programming\n                http://www.AnalysisAndSolutions.com/\n        4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335\n"},{"id":"224533","messageId":"20130803170116.GE945@analysisandsolutions.com","threadId":"34603","inReplyTo":"20130803165728.GB2893@elie.Belkin","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Daniel Convissor","fromEmail":"danielc@analysisandsolutions.com","sentAt":"2013-08-03T17:01:16Z","receivedAt":"2013-08-03T17:01:16Z","isPatch":false,"sender":{"key":"danielc@analysisandsolutions.com","avatar":"https://gravatar.com/avatar/6934d176616faccef0fe2329329c24e2a2d92783d565704c7c4f85ea9219d412?d=mp&s=160"},"body":"Heya:\n\nOn Sat, Aug 03, 2013 at 09:57:28AM -0700, Jonathan Nieder wrote:\n> \n> Adam hadn't made a commit, so that wouldn't work in this case.\n\nOh, good catch.  I saw the add and assumed there was a commit there.\n\n--Dan\n\n-- \n T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y\n            data intensive web and database programming\n                http://www.AnalysisAndSolutions.com/\n        4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335\n"},{"id":"224544","messageId":"CAJOTJ-D6Aho_NJscXtu74Ok7u5sQmHn_L_Nma_F1kn9O6y95UQ@mail.gmail.com","threadId":"34603","inReplyTo":"20130803165728.GB2893@elie.Belkin","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Adam A","fromEmail":"hitsthings@gmail.com","sentAt":"2013-08-03T21:46:47Z","receivedAt":"2013-08-03T21:46:47Z","isPatch":false,"sender":{"key":"hitsthings@gmail.com","avatar":null},"body":"On Sun, Aug 4, 2013 at 2:57 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Daniel Convissor wrote:\n>\n>> All is not lost.  Your local files should be stored in the repository's\n>> reflog.  Examine the output of \"git reflog\".  You can then reset your\n>> working directory to obtain those files by doing something _like_\n>> \"git reset --hard HEAD@{1}\".\n>\n> Adam hadn't made a commit, so that wouldn't work in this case.\n>\n> \"git fsck --lost-found\" should be helpful, but yeah, this is a bug.\n> See for example [1] for the start of a patch to play with (needs\n> tests).\n\nAh I didn't realize the objects would still be there! `git fsck` +\n`git show` is a wonderful workaround until the bug is fixed.\n\n>\n> Thanks and hope that helps,\n> Jonathan\n>\n> [1] http://thread.gmane.org/gmane.comp.version-control.git/196502/focus=196503\n\n\nThanks so much guys!\nAdam\n"},{"id":"224999","messageId":"20130810073343.GE30185@sigill.intra.peff.net","threadId":"34603","inReplyTo":"20130803165728.GB2893@elie.Belkin","subject":"Re: Bug: Pulling remotes into an empty repo deletes the index","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-08-10T07:33:43Z","receivedAt":"2013-08-10T07:33:43Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 03, 2013 at 09:57:28AM -0700, Jonathan Nieder wrote:\n\n> > All is not lost.  Your local files should be stored in the repository's\n> > reflog.  Examine the output of \"git reflog\".  You can then reset your\n> > working directory to obtain those files by doing something _like_\n> > \"git reset --hard HEAD@{1}\".\n> \n> Adam hadn't made a commit, so that wouldn't work in this case.\n> \n> \"git fsck --lost-found\" should be helpful, but yeah, this is a bug.\n> See for example [1] for the start of a patch to play with (needs\n> tests).\n\nIf I understand the situation correctly, this is actually already fixed\nin v1.8.3.3 and higher by b4dc085 (pull: merge into unborn by\nfast-forwarding from empty tree, 2013-06-20).\n\n-Peff\n"}]}