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 into 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. You can also use gitignore.io to create a .gitignore file for your operating system, programming language, or 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
.gitignorefile for your repository.touch .gitignoreIf the command succeeds, there will be no output.
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