How to Skip Specific Files When Adding Changes in Git

Javascript Jeep🚙💨
2 min readAug 28, 2024
Photo by Roman Synkevych on Unsplash

When working with Git, there are times when you want to stage multiple changes but skip a few specific files. In this post, we’ll explore different methods to skip specific files and add all other changes to your Git staging area.

Method 1: Add All Changes and Then Unstage Specific Files

One of the simplest ways to handle this is to add everything first and then unstage the files you don’t want to include in the commit.

Steps:

  1. Use the git add . command to add all changes:
git add .

2. Unstage specific files by using git reset:

git reset <file1> <file2> ...

Example:

If you want to add all changes except config.json, you can do:

git add .
git reset config.json

Now, all changes except config.json are staged.

Method 2: Add All Files Except Specific Ones Using git add --

Git allows you to exclude specific files while staging everything else using patterns.

Use the git add -- :!<file> syntax to exclude files.

--

--