为什么不把git pull带回我删除的目录? [英] Why doesn't git pull bring back directories that I've deleted?

查看:1854
本文介绍了为什么不把git pull带回我删除的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习如何使用 git 今天进展顺利。



作为一个实验,我使用 push 来上传两个目录(每个包含两个文件)和两个根目录下的文件。这工作得很好。



然后我删除了我在本地的两个目录之一(但不在git上)。当我使用 git status 时,似乎知道这一点:


deleted:test / Testfile.as

已删除:test / Testile2.as


但是当我使用 git pull 取回我的文件时,它们似乎并不返回到我的本地文件夹。我也试过 git fetch



我似乎能够将所有东西都还回来的唯一方法是 git clone ,但这似乎不合逻辑,因为我需要在本地删除我的主目录,然后再次克隆它(或者为克隆文件指定一个新位置)。



从github上检索文件和文件夹的适当方式是否已经在本地删除? 方案 git pull 只是在工作目录中合并提取的提交文件,不会恢复已删除的目录(但可能会提醒您有关冲突。) p>

如果您删除了工作目录中的文件夹,则必须执行以下操作:

  git checkout  - 测试

将其恢复。



或者您可以执行 git reset --hard 以将您的工作目录完全移至HEAD状态。


I've just started learning how to use git today, progressing well.

As an experiment, I used push to upload two directories (containing two files each) and two files in the root directory. This worked fine.

I then deleted one of the two directories that I have locally (but not on git). When I use git status it seems to be aware of this:

deleted: test/Testfile.as
deleted: test/Testile2.as

But when I use git pull to get my files back, they don't seem to return to my local folder. I've also tried git fetch.

The only way I seem to be able to get everything back is git clone, but that doesn't seem logical as I need to delete my master directory locally and then clone it back again (or alternatively specify a new location for the cloned files).

What is the appropriate way to retrieve files and folders from github that have been deleted locally?

解决方案

git pull just merges the fetched commits in your working directory and will not restore your deleted directory ( but might warn you about conflicts.)

If you have deleted the folders in your working directory, you have to do:

git checkout -- test

to get it back.

Or you can do git reset --hard to completely bring your working directory to HEAD state.

这篇关于为什么不把git pull带回我删除的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆