Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9242621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:37:05+00:00 2026-06-18T08:37:05+00:00

So I added a remote, empty repository to a local repository that was just

  • 0

So I added a remote, empty repository to a local repository that was just initialized, and made the mistake of pulling before committing my local changes:

git init
git remote add origin <URL>
git add *
git pull origin master

Now all my files have been removed because git wrote the empty repo into the local one.

Normally, when pulling, git refused to merge if there were unstaged local changes that needed committing. I’m surprised that this is different with the initial commit.

git log shows only the initial commit since I never committed the local changes, so I can’t undo the pull using git reset --hard. Is there a way to restore my files and if so, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:37:06+00:00Added an answer on June 18, 2026 at 8:37 am

    Judging by the work-flow you gave above, it appears that you staged your files. That should leave some dangling blobs out there, that you should be able to recover.

    git fsck --lost-found
    

    That should commit the changes to a file in .git/lost-found. Something might show up there.

    Further discussion: Recover file after git pull, Recovering added file after doing git reset –hard HEAD^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created remote repositories (release and snapshot) from local repository. Both new remote reposotories
There is a Git repository on a server that my colleague and I both
A large binary file was added to my git repository 20 commits ago. Removing
Hi Im running linux angstrom distribution on a remote device, I added .bash_profile and
How to remove a blank page that gets added automatically after \part{} or \chapter{}
I am looking for an API that can remove bundle items added in a
I ran the following command to clone an SVN repository: git svn clone -s
I have the div event_wrapper that can be dynamically added on a page by
how to check that if any item String is added in array and that
So far i only used GIT to version control my local files, i am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.