git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Daniel Convissor <danielc@analysisandsolutions.com>
To: Adam A <hitsthings@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Bug: Pulling remotes into an empty repo deletes the index
Date: Sat, 3 Aug 2013 12:39:15 -0400	[thread overview]
Message-ID: <20130803163915.GB945@analysisandsolutions.com> (raw)
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:
> - 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

  reply	other threads:[~2013-08-03 16:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJOTJ-AVamimToPo4oQ=O_Pg+mJHQhardO+NfU8b1dvRxg1KMA@mail.gmail.com>
2013-08-03 12:01 ` Bug: Pulling remotes into an empty repo deletes the index Adam A
2013-08-03 16:39   ` Daniel Convissor [this message]
2013-08-03 16:57     ` Jonathan Nieder
2013-08-03 17:01       ` Daniel Convissor
2013-08-03 21:46       ` Adam A
2013-08-10  7:33       ` Jeff King
2013-08-03 16:59     ` Daniel Convissor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130803163915.GB945@analysisandsolutions.com \
    --to=danielc@analysisandsolutions.com \
    --cc=git@vger.kernel.org \
    --cc=hitsthings@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).