wp code snippet

WordPress, PHP quick help codes

How to ignore files and directory with .gitignore in Git

.gitignore file helps us to ignore any matching files and directory with a list of patterns that listed in .gitignore on each git add.

Here are some examples which help to exclude files and directories from git repository commits.

Create .gitignore file

touch .gitignore

.gitignore patterns

.gitignore files are matched from the root directory of the fit repository. Patterns used a wildcard character * to match any character and literal characters to match the exact phrase.

Example 1:
*.log

This example will exclude all the files ending in .log

Example 2:
*.log*

This example will exclude all the files that matches any character before and after .log

Example 3:
/directory/*

This example will exclude all files in a specific path

Categories: Git

Leave a Reply

%d bloggers like this: