简体   繁体   English

忽略dir / *和dir /与dir之间的Git区别

[英]Git difference between ignore dir/* and dir/ and dir

I was surprised when I did git pull and an untracked directory got deleted. 当我执行git pull并删除了未跟踪的目录时,我感到很惊讶。

I'm wondering if it is related to my .gitignore file. 我想知道它是否与我的.gitignore文件有关。

For that particular folder, I have: 对于该特定文件夹,我有:

/path/to/folder/*

Whereas for some other folders I have: 而对于其他一些文件夹,我有:

/path/to/folder/

Is there a difference, especially as pertains to what happens to the files in that folder when I do git pull ? 有什么区别,尤其是当我执行git pull时,该文件夹中的文件发生了什么变化?

Note: I backed up the files before hand, so I was able to restore them. 注意:我事先备份了文件,因此能够还原它们。 But in the future I will need to be able to git pull without having this potential disaster on my hands. 但是将来,我将需要能够在不承受这种潜在灾难的情况下进行git pull

git doesnt track empty directory. git不跟踪空目录。 Once you got some files in there and if you run git status it will show the dir/ as untracked. 一旦您在其中找到了一些文件,并且如果您运行git status,它将显示dir /为未跟踪。 That means: anything in dir folder I am not tracking. 这意味着:dir文件夹中的任何内容我都没有跟踪。

.gitignore file is used in git status: When you run git status it compares your working directory with Index and uses .gitignore to ignore the files mentioned. .gitignore文件以git状态使用:运行git status时,它将工作目录与Index进行比较,并使用.gitignore忽略提到的文件。

When you run git pull- it runs fetch and merge. 当您运行git pull-时,它将运行获取和合并。 It will not remove your untracked directories and files but merges with incoming changes from remote. 它不会删除未跟踪的目录和文件,但会与来自远程的传入更改合并。

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

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