.gitignore
will prevent untracked files from being added (without an add -f
) to the set of files tracked by Git. Following the simplest example of a gitignore file.
The following example shows that how wen ignore a file or a folder using git ignore
Add a tracked file to gitignore:
When any file tracked by git and you add it to git ignore However, Git will continue to track any files that are already being tracked.
To stop tracking a file, we must remove it from the index
git rm --cached config.php
To remove a folder and all files in the folder recursively:
git rm -r --cached assets