git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug: Pulling remotes into an empty repo deletes the index

From
Daniel Convissor <danielc@analysisandsolutions.com>
Date
Aug 3, 2013, 16:39 UTC
Message-ID
<20130803163915.GB945@analysisandsolutions.com>
In-Reply-To
<CAJOTJ-Cgdg4CQs-3t1CsBkq_feVEpkoASzQSTATiVugjs+LL7w@mail.gmail.com>
Hi Adam:
On Sat, Aug 03, 2013 at 10:01:30PM +1000, Adam A wrote:
Show 11 quoted lines
> - create a remote repository at URL with commit(s) in it
>   - e.g., a new github repo with README and LICENSE files auto-added
> - write some files in a local directory
> - git init
> - git add .
>   - the contents of the directory are now in the index
> - git remote add origin URL
> - git pull origin master
> 
> The local files added to the index are now completely wiped out and
> replaced with the remote content. I lose all my previous work. :/

All is not lost. Your local files should be stored in the repository's reflog. Examine the output of "git reflog". You can then reset your working directory to obtain those files by doing something _like_ "git reset --hard HEAD@{1}".

All hail reflog.
Good luck,
--Dan
-- 
 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
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
        4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335
Previous: Adam ANext: Jonathan Nieder
Message 2 of 7 in “Re: Bug: Pulling remotes into an empty repo deletes the index”
  1. Adam AAug 3, 2013
  2. Daniel ConvissorAug 3, 2013
  3. Jonathan NiederAug 3, 2013
  4. Daniel ConvissorAug 3, 2013
  5. Adam AAug 3, 2013
  6. Jeff KingAug 10, 2013
  7. Daniel ConvissorAug 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.