Aditya Verma
Aditya Verma

Reputation: 518

How to stage all tracked modified files?

Okay, This might be a silly question, but I am new to git, and getting confused a lot.

I have made some files on IntelliJ and now when I run git status in my IntelliJ terminal I get this:

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)

  new file:  file x
  new file:  file y
  new file:  file z

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)

 Modified: file x
 Modified: file y
 Modified: file z

Untracked files:
  (use "git add <file>..." to include in what will be committed) 

  file a 
  file b

I want to stage and commit the file x, file y, file z and do not want to stage the file a and file b.

I know git add . will stage all tracked and untracked files. Can something like git add -u do the job?

Note: There are a lot of files and I don't want to individually add them all.

Upvotes: 6

Views: 7280

Answers (2)

Adil B
Adil B

Reputation: 16866

Yes - use the git add -u command when you want Git to stage all your modifications to the files it's currently tracking across your entire repository.

Upvotes: 11

CodeWizard
CodeWizard

Reputation: 142632

There are a lot many files and I don't want to individually add them all.

You can use git ignore and git will not add those files

### .gitignroe
<b full path>

Important: don't forget to add and commit your .gitignore file.


How to get a list of ignored files?

git check-ignore -v <path>

Upvotes: 1

Related Questions