-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added gitignore.md under git/concepts/gitignore (#6047)
* initial commit, added gitignore.md under git/concepts/gitignore * added new entry on the Multilevel Inheritance term under C++ * Revert "added new entry on the Multilevel Inheritance term under C++" This reverts commit 21029b3. * new concept entry gitignore.md * Update gitignore.md * minor fixes ---------
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
Title: '.gitignore' | ||
Description: 'A configuration file that instructs Git to ignore specific files and directories when tracking changes in a repository.' | ||
Subjects: | ||
- 'Code Foundations' | ||
- 'Developer Tools' | ||
Tags: | ||
- 'Git' | ||
- 'GitHub' | ||
- 'Version Control' | ||
CatalogContent: | ||
- 'learn-git' | ||
- 'learn-the-command-line' | ||
--- | ||
|
||
A **.gitignore** file specifies the files and directories that Git should ignore when tracking changes in a repository. This is particularly useful for excluding build artifacts, temporary files, dependencies, and sensitive information from version control. The .gitignore file should be located in the root directory of a repository. | ||
|
||
## Common .gitignore patterns | ||
|
||
Below are common patterns typically included in .gitignore files: | ||
|
||
```plaintext | ||
# Ignore node modules directory | ||
node_modules/ | ||
# Ignore build output directories | ||
dist/ | ||
build/ | ||
# Ignore environment files | ||
.env | ||
.env.local | ||
# Ignore log files | ||
*.log | ||
# Ignore system files | ||
.DS_Store | ||
Thumbs.db | ||
# Ignore IDE specific files | ||
.idea/ | ||
.vscode/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
``` | ||
|
||
## Creating a .gitignore file | ||
|
||
Step 1: Create a new .gitignore file in the repository's root directory: | ||
|
||
```shell | ||
touch .gitignore | ||
``` | ||
|
||
Step 2: Open the file in the preferred text editor and specify the files and directories to ignore: | ||
|
||
```shell | ||
# Open with VS Code | ||
code .gitignore | ||
|
||
# Open with Vim | ||
vim .gitignore | ||
``` | ||
|
||
> **Note:** Wildcards like '\*' can be used for pattern matching and '#' for comments in the .gitignore file. | ||
## Common .gitignore rules | ||
|
||
1. Specific file: `filename.txt` | ||
2. File pattern: `*.log` | ||
3. Directory: `node_modules/` | ||
4. Nested directory: `**/logs/` | ||
5. Negation (don't ignore): `!important.log` | ||
|
||
> **Note:** If ignored files have already been committed, remove them from Git's tracking using `git rm --cached <file>` before .gitignore takes effect. |