* Re: Bug: Pulling remotes into an empty repo deletes the index
[not found] <CAJOTJ-AVamimToPo4oQ=O_Pg+mJHQhardO+NfU8b1dvRxg1KMA@mail.gmail.com>
@ 2013-08-03 12:01 ` Adam A
2013-08-03 16:39 ` Daniel Convissor
0 siblings, 1 reply; 7+ messages in thread
From: Adam A @ 2013-08-03 12:01 UTC (permalink / raw)
To: git
Hello, the project readme on github points here for submitting bug
reports, but please let me know if I'm in the wrong place.
Steps to reproduce:
- 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. :/
This was pretty painful for me to lose a few days of work. I also
couldn't stash my changes which I tried first, but git refused without
an initial commit.
Would have been nice if git warning me about the destructive operation.
Cheers,
Adam
On Sat, Aug 3, 2013 at 9:57 PM, Adam A <hitsthings@gmail.com> wrote:
> Hello, the project readme on github points here for submitting bug reports,
> but please let me know if I'm in the wrong place.
>
> Steps to reproduce:
>
> - 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. :/
>
> This was pretty painful for me to lose a few days of work. I also couldn't
> stash my changes which I tried first, but git refused without an initial
> commit.
>
> Would have been nice if git warning me about the destructive operation.
>
> Cheers,
> Adam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug: Pulling remotes into an empty repo deletes the index
2013-08-03 12:01 ` Bug: Pulling remotes into an empty repo deletes the index Adam A
@ 2013-08-03 16:39 ` Daniel Convissor
2013-08-03 16:57 ` Jonathan Nieder
2013-08-03 16:59 ` Daniel Convissor
0 siblings, 2 replies; 7+ messages in thread
From: Daniel Convissor @ 2013-08-03 16:39 UTC (permalink / raw)
To: Adam A; +Cc: git
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug: Pulling remotes into an empty repo deletes the index
2013-08-03 16:39 ` Daniel Convissor
@ 2013-08-03 16:57 ` Jonathan Nieder
2013-08-03 17:01 ` Daniel Convissor
` (2 more replies)
2013-08-03 16:59 ` Daniel Convissor
1 sibling, 3 replies; 7+ messages in thread
From: Jonathan Nieder @ 2013-08-03 16:57 UTC (permalink / raw)
To: Daniel Convissor; +Cc: Adam A, git
Daniel Convissor wrote:
> 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}".
Adam hadn't made a commit, so that wouldn't work in this case.
"git fsck --lost-found" should be helpful, but yeah, this is a bug.
See for example [1] for the start of a patch to play with (needs
tests).
Thanks and hope that helps,
Jonathan
[1] http://thread.gmane.org/gmane.comp.version-control.git/196502/focus=196503
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug: Pulling remotes into an empty repo deletes the index
2013-08-03 16:39 ` Daniel Convissor
2013-08-03 16:57 ` Jonathan Nieder
@ 2013-08-03 16:59 ` Daniel Convissor
1 sibling, 0 replies; 7+ messages in thread
From: Daniel Convissor @ 2013-08-03 16:59 UTC (permalink / raw)
To: Adam A; +Cc: git
Hey Again Adam:
On Sat, Aug 03, 2013 at 12:39:15PM -0400, Daniel Convissor wrote:
>
> 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}".
A further thought. The most useful thing to do would probably be along
these lines...
git reflog # as mentioned before
git checkout -b myinitialstuff HEAD@{<desired number>}
git log
git checkout master
git cherry-pick <hash of your first local commit>
--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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug: Pulling remotes into an empty repo deletes the index
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
2 siblings, 0 replies; 7+ messages in thread
From: Daniel Convissor @ 2013-08-03 17:01 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Adam A, git
Heya:
On Sat, Aug 03, 2013 at 09:57:28AM -0700, Jonathan Nieder wrote:
>
> Adam hadn't made a commit, so that wouldn't work in this case.
Oh, good catch. I saw the add and assumed there was a commit there.
--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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug: Pulling remotes into an empty repo deletes the index
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
2 siblings, 0 replies; 7+ messages in thread
From: Adam A @ 2013-08-03 21:46 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Daniel Convissor, git
On Sun, Aug 4, 2013 at 2:57 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Daniel Convissor wrote:
>
>> 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}".
>
> Adam hadn't made a commit, so that wouldn't work in this case.
>
> "git fsck --lost-found" should be helpful, but yeah, this is a bug.
> See for example [1] for the start of a patch to play with (needs
> tests).
Ah I didn't realize the objects would still be there! `git fsck` +
`git show` is a wonderful workaround until the bug is fixed.
>
> Thanks and hope that helps,
> Jonathan
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/196502/focus=196503
Thanks so much guys!
Adam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug: Pulling remotes into an empty repo deletes the index
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
2 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2013-08-10 7:33 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Daniel Convissor, Adam A, git
On Sat, Aug 03, 2013 at 09:57:28AM -0700, Jonathan Nieder wrote:
> > 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}".
>
> Adam hadn't made a commit, so that wouldn't work in this case.
>
> "git fsck --lost-found" should be helpful, but yeah, this is a bug.
> See for example [1] for the start of a patch to play with (needs
> tests).
If I understand the situation correctly, this is actually already fixed
in v1.8.3.3 and higher by b4dc085 (pull: merge into unborn by
fast-forwarding from empty tree, 2013-06-20).
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-08-10 7:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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
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
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).