Ignoring files in git

By default, all files that we add to working directory are tracked by Git. But sometimes, we do not bother about changes in those files. For example – Consider maven project. When the project is built using maven, it creates target directory. We are not interested in storing this directory and all it’s contents. How to tell Git not to track specific files? That’s when .gitignore comes into picture. .gitignore is the special file that can be created and stored in the root of the Git repository. It contains the list of files or directories that should be ignored. Here is the sample .gitignore file contents for various types of Java project. Notice that to ignore directory and its entire contents you have to use / at the end of directory name.

Files to be ignored for IntelliJ IDEA Project

.idea/ *.iml *.iws

Files to be ignored for Maven Project

target/ log/

Files to be ignored for Eclipse Project

.classpath .project

To ignore all files ending with .xml

*.xml Below example shows that even though we create and change the XML file, Git does not track it as we have added *.xml line in .gitignore file.
  • gitignore example in Git
  • gitignore example in Git

Web development and Automation testing

solutions delivered!!