Versión del artículo: GitHub.com
Ignorar archivos
You can configure Git to ignore files you don't want to check in to GitHub.
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. También puedes usar gitignore.io para crear un archivo .gitignore para tu sistema operativo, lenguaje de programación o IDE. For more information, see "github/gitignore" and the "gitignore.io" site.
- Open TerminalTerminalGit Bash.
- Navigate to the location of your Git repository.
- 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. Por ejemplo, puedes crear el archivo en ~/.gitignore_global y agregarle algunas normas.
- Open TerminalTerminalGit Bash.
- 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
Si no quieres crear un archivo .gitignore para compartir con otros, puedes crear normas que no estén confirmadas con el repositorio. Puedes utilizar esta técnica para los archivos generados de forma local que no esperas que otros usuarios generen, tales como los archivos creados por tu editor.
Utiliza tu editor de texto favorito para abrir el archivo llamado .git/info/exclude dentro de la raíz de tu repositorio de Git. Cualquier norma que agregues aquí no se registrará y solo ignorará archivos de tu repositorio local.
- Open TerminalTerminalGit Bash.
- Navigate to the location of your Git repository.
- Utilizando tu editor de texto favorito, abre el archivo .git/info/exclude.
Leer más
- Ignoring files in the Pro Git book
- .gitignore in the man pages for Git
- A collection of useful .gitignore templates in the github/gitignore repository
- gitignore.io site