Hallo, Entdecker! An dieser Seite wird aktiv gearbeitet, oder sie wird noch übersetzt. Die neuesten und genauesten Informationen finden Sie in unserer englischsprachigen Dokumentation.
Artikelversion: GitHub.com

Dateien ignorieren

You can configure Git to ignore files you don't want to check in to GitHub.

Inhalt dieses Artikels

Configuring ignored files for a single repository

You can create a .gitignore file in your repository's root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the .gitignore file in to your repository.

GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore public repository. Sie können auch mit gitignore.io eine .gitignore-Datei für Ihr Betriebssystem, Ihre Programmiersprache oder Ihre IDE erstellen. For more information, see "github/gitignore" and the "gitignore.io" site.

  1. Open TerminalTerminalGit Bash.
  2. Navigate to the location of your Git repository.
  3. Create a .gitignore file for your repository.
    $ touch .gitignore

For an example .gitignore file, see "Some common .gitignore configurations" in the Octocat repository.

If you want to ignore a file that is already checked in, you must untrack the file before you add a rule to ignore it. From your terminal, untrack the file.

$ git rm --cached FILENAME

Configuring ignored files for all repositories on your computer

You can also create a global .gitignore file to define a list of rules for ignoring files in every Git repository on your computer. Sie können z. B. eine Datei unter ~/.gitignore_global erstellen und ihr dann einige Regeln hinzufügen.

  1. Open TerminalTerminalGit Bash.
  2. Configure Git to use the exclude file ~/.gitignore_global for all Git repositories.
    $ git config --global core.excludesfile ~/.gitignore_global

Excluding local files without creating a .gitignore file

Wenn Sie keine .gitignore-Datei erstellen und für andere freigeben möchten, können Sie Regeln erstellen, die nicht in das Repository committet werden. Sie können diese Methode für lokal erstellte Dateien anwenden, bei denen es unwahrscheinlich ist, dass andere sie erzeugen, z. B. Dateien, die von Ihrem Editor erstellt wurden.

Öffnen Sie die Datei .git/info/exclude im Root Ihres Git-Repositorys mit Ihrem bevorzugten Texteditor. Alle Regeln, die Sie hier hinzufügen, werden nicht eingecheckt und ignorieren nur Dateien für Ihr lokales Repository.

  1. Open TerminalTerminalGit Bash.
  2. Navigate to the location of your Git repository.
  3. Öffnen Sie die Datei .git/info/exclude mit Ihrem bevorzugten Texteditor.

Weiterführende Informationen

Menschliche Unterstützung einholen

Sie können das Gesuchte nicht finden?

Kontakt