简体   繁体   English

从 github 中排除文件夹

[英]Exclude folder from github

I need to exclude the folder App_Data from my Github but i don't know how.我需要从我的 Github 中排除文件夹 App_Data,但我不知道如何。

I have a application which saves many files like jpg files in the directory: Source\\MyProject\\App_data\\stored\\filename.jpg我有一个应用程序,它在目录中保存了许多文件,如 jpg 文件:Source\\MyProject\\App_data\\stored\\filename.jpg

Now i need to exclude this from the .gitignore file现在我需要从 .gitignore 文件中排除它

I don't know how to do this so i am looking for a example我不知道该怎么做,所以我正在寻找一个例子

  1. Create a file called .gitignore in your repository.在您的存储库中创建一个名为 .gitignore 的文件。
  2. Add the text "App_Data" to this file.将文本“App_Data”添加到此文件中。
  3. Save.节省。

It should do exactly what you want.它应该完全符合您的要求。 It will exclude files/folders with that string from your local repository path (the path where .gitignore is stored).它将从本地存储库路径(存储 .gitignore 的路径)中排除带有该字符串的文件/文件夹。

Keep in mind, this is not your only option.请记住,这不是您唯一的选择。 I'd read the help document linked below for a better understanding to get exactly what you need accomplished.我会阅读下面链接的帮助文档,以便更好地了解您需要完成的工作。

See here for more info: GitHub Help - Ignoring Files有关更多信息,请参见此处: GitHub 帮助 - 忽略文件

简单地把它放在你的.gitignore文件中(假设MyProject是你的 git root):

App_data

Per https://help.github.com/articles/ignoring-files根据https://help.github.com/articles/ignoring-files

From time to time there are files you don't want git to track.不时有您不希望 git 跟踪的文件。 There are a few methods of telling git what files to ignore.有几种方法可以告诉 git 忽略哪些文件。

If you create a file in your repository named .gitignore git will use its rules when looking at files to commit.如果您在存储库中创建一个名为.gitignore的文件,git 在查看要提交的文件时将使用其规则。 Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it.请注意,在将规则添加到此文件以忽略它之前,git 不会忽略已跟踪的文件。 In such a case the file must be un-tracked, usually with git rm --cached filename在这种情况下,必须取消跟踪文件,通常使用git rm --cached filename

This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository.该文件可以提交到存储库中,从而与克隆存储库的任何其他用户共享规则列表。

In case you need to ignore a whole folder which was already tracked, do not forget to do it recursively with -r.如果您需要忽略已跟踪的整个文件夹,请不要忘记使用 -r 递归执行此操作。

  1. Add foldername/ to .gitignore将文件夹名/ 添加到 .gitignore

  2. git rm -r --cached foldername/

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

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