Nisha
Nisha

Reputation: 9

How to exclude only one file in add in Git?

I need to exclude only one file when I add files for commit. Say my commit directory ..\Git_Folder and I need to exclude only Git_SubFolder/x.sdf.

How to do that?

Upvotes: 0

Views: 175

Answers (3)

Jonathan.Brink
Jonathan.Brink

Reputation: 25373

A quick way could be to reset that one file like this:

git add .
git reset x.sdf

This would bring the changes to x.sdf back to your working directory. To totally exclude that file from being staged by Git include it in your .gitignore file.

Upvotes: 3

James Kirsch
James Kirsch

Reputation: 72

You can add the file extension to your .gitignore file.

A convenient way to tell which files you should naturally ignore is through this site. Which will help you filter out files that shouldn't be included in the Repository for these project types.

Also see the official documentation for examples as provided here.

Hope that helps!

Upvotes: 0

CodeWizard
CodeWizard

Reputation: 141946

several options:

.gitignore

Add the file to .gitignore file

// .gitignore content
x.sdf

assume-unchanged

use this on the file which you don't want git to track

git update-index --no-assume-unchanged <file>

Use this site to generate your desired ignore file
https://www.gitignore.io/

Upvotes: 1

Related Questions