0

In short: I want to undo a pull

I looked at similar questions, but none of those answers worked for me.

Here's why my situation might be different. I created a new repository on GitHub. On that repository I add a LICENSE file and a README.md file.

I had code that I wanted to push to that remote repository which was not using git previously.

Essentially I did a pull from the remote repository, which only had two files, into a repository with many files. This ended up deleting the files and directories that I had in the local repository.

I want to know if I can undo this, or this I just commit a big no-no in how I used git?

Here's is my list of commands

user1@debian:~/code/python/frameworks/django/charity$ ls
accounts  charity  customusers  main  manage.py  products


user1@debian:~/code/python/frameworks/django/charity$ git init
Initialized empty Git repository in /home/drone-  
xb81/code/python/frameworks/django/charity/.git/


user1@debian:~/code/python/frameworks/django/charity$ ls -a
.   accounts  customusers  main       products
..  charity   .git         manage.py


user1@debian:~/code/python/frameworks/django/charity$ git remote add origin
https://github.com/giovannicode/charity-shop


user1@debian:~/code/python/frameworks/django/charity$ git add --all


user1@debian:~/code/python/frameworks/django/charity$ git pull origin master
From https://github.com/giovannicode/charity-shop
* branch            master     -> FETCH_HEAD


user1@debian:~/code/python/frameworks/django/charity$ git status
# On branch master
nothing to commit (working directory clean)


user1@debian:~/code/python/frameworks/django/charity$ git fetch


user1@debian:~/code/python/frameworks/django/charity$ ls
LICENSE  README.md

My last command shows that I no longer have any of my old files or directories? Did I misuse git or is there a way for me to get my files back?

Let me know me if you need additional information.

Thanks in advance.

user1631075
  • 345
  • 2
  • 5
  • 11
  • Can you find the id of your last commit when you run "git log"? – Gareth Oct 01 '14 at 15:26
  • See http://stackoverflow.com/a/10368052/1256452 for notes on the `pull` bug that can lose files, if your git is older than 1.8.4. (You can usually get the files back; see that answer.) – torek Oct 01 '14 at 15:40
  • @Gareth My output is just user1@debian:~/code/python/frameworks/django/charity$ git logcommit 5a6f768ad30e3a8e5732729b03f7ad8dfc3d548f Author: Giovanni Arroyo <****************gmail.com> Date: Wed Oct 1 08:19:53 2014 -0500 Initial commit – user1631075 Oct 01 '14 at 16:11

1 Answers1

1

Presuming the git add --all you ran actually worked, you can attempt to recover your files from Recovering Staged Files

Community
  • 1
  • 1
Andrew C
  • 13,845
  • 6
  • 50
  • 57