What is the purpose of .gitignore?
a) To specify files and directories that Git should ignore
b) To reset the repository
c) To clone a repository
d) To view the commit history
Answer:
a) To specify files and directories that Git should ignore
Explanation:
The .gitignore file is used to specify files and directories that Git should ignore. This prevents certain files (such as temporary files, build outputs, or sensitive information) from being tracked or included in commits.
For example, a typical .gitignore might include entries like *.log to ignore all log files or node_modules/ to ignore the node_modules directory in a JavaScript project.
Using .gitignore helps keep your repository clean by excluding unnecessary or sensitive files from version control.