简体   繁体   English

撤消从新的远程存储库到本地文件的git pull?

[英]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. 我在GitHub上创建了一个新的存储库。 On that repository I add a LICENSE file and a README.md file. 在该存储库上,我添加了一个LICENSE文件和一个README.md文件。

I had code that I wanted to push to that remote repository which was not using git previously. 我有想要推送到以前未使用git的远程存储库的代码。

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? 我想知道是否可以撤消此操作,或者我只是对使用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? 我滥用git还是有办法找回我的文件?

Let me know me if you need additional information. 如果您需要其他信息,请告诉我。

Thanks in advance. 提前致谢。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git入门-从远程TFS服务器进入本地存储库? - Getting started with Git - pull into local repository from a remote TFS server? Git从远程计算机将存储库拉到本地计算机 - Git pull a repository to local computer from a remote computer 如何从远程git存储库一次提取一个提交? - How to pull one commit at a time from a remote git repository? 如何将已建立的本地git存储库链接到新的远程存储库并将所有文件推送到远程? - How do I link an already established local git repository to a new remote repository and push all files to remote? Visual Studio Code - 连接到远程 Git 存储库并将本地文件推送到新的远程存储库 - Visual Studio Code - Connect to a remote Git repository and PUSH local files to a new remote repository 万一本地存储库的唯一更改来自远程存储库,则存在“ git pull”的危险 - Dangers of 'git pull' in case the only changes to local repository come from the remote repository 撤消错误的github存储库中的pull - undoing a pull from the wrong github repository 如何从本地创建远程 Git 存储库? - How to create a remote Git repository from a local one? 从远程git存储库中提取更改 - Pull changes from remote git repository git从远程存储库中提取所有分支 - git pull all branches from remote repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM