简体   繁体   中英

undoing a git pull from a new remote repository to a local one with files in it?

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.

假设git add --all您所运行的全部工作正常,则可以尝试从“ 恢复 git add --all的文件”中恢复文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM