pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://docs.github.com/zh/get-started/git-basics/ignoring-files

-head=""/>
Skip to main content

忽略文件

你可以配置 Git 忽略你不想检入 GitHub 的文件。

Platform navigation

为单个仓库配置忽略的文件

可以在存储库的根目录中创建 .gitignore 文件,指示 Git 在提交时要忽略哪些文件和目录。 若要与克隆存储库的其他用户共享忽略规则,请将 .gitignore 该文件提交到存储库中。

GitHub在“github/gitignore”公共存储库中维护了一个官方列表,列出许多流行的操作系统、环境和语言的推荐.gitignore文件。 还可以使用 gitignore.io 创建 .gitignore 文件,以用于操作系统、编程语言或 IDE。 有关详细信息,请参阅 github/gitignoregitignore.io 站点。

  1. 打开终端终端Git Bash

  2. 导航到 Git 仓库的位置。

  3. 为存储库创建 .gitignore 文件。

    touch .gitignore
    

    如果命令成功,则不会有输出。

有关 .gitignore 文件的示例,请参阅 Octocat 存储库中的一些常见 .gitignore 配置

如果想要忽略已检入的文件,必须先取消对该文件的跟踪,然后再添加忽略文件的规则。 在您的终端中取消对文件的跟踪。

git rm --cached FILENAME

为计算机上的所有存储库配置忽略的文件

在计算机上的任何 Git 存储库中提交时,可以指示 Git 始终忽略特定文件或目录。 例如,可以使用此功能忽略文本编辑器创建的任何临时备份文件。

要始终忽略特定文件或目录,请将其添加到目录 ignore 中名为 ~/.config/git 的文件。 默认情况下,Git 会忽略全局配置文件 ~/.config/git/ignore 中列出的任何文件和目录。 如果 git 目录和 ignore 文件尚不存在,可能需要创建它们。

不创建 .gitignore 文件而排除本地文件

如果不想创建与其他人共享的 .gitignore 文件,可以创建不随存储库提交的规则。 您可以对不希望其他用户生成的本地生成文件使用此方法,例如编辑者创建的文件。

使用偏好的文本编辑器打开 Git 存储库根目录中名为 .git/info/exclude 的文件。 您在此处添加的任何规则都不会检入,并且只会对您的本地仓库忽略文件。

  1. 打开终端终端Git Bash
  2. 导航到 Git 仓库的位置。
  3. 使用偏好的文本编辑器打开文件 .git/info/exclude

深入阅读

  •           Git 文档中的[忽略文件](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring)
    
  • Git 文档中的 .gitignore
  • github/gitignore 存储库中的_有用的 .gitignore 模板集合_
  • gitignore.io 站点
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy