How to Add All Files in Git ?
Last Updated :
14 May, 2024
Adding all files in Git is a common task when you want to stage all changes for committing. Adding all files in Git involves staging all modifications, additions, and deletions in your working directory for the next commit. This process ensures that all changes are included in the commit history. In this article, we will see the detailed guide for adding all files in Git.
What is Git's staging Area?
Before diving into adding files in Git, It's important to know about the concept of the staging area. The staging area, also known as the index, acts as a middle ground between your working directory and the repository. It serves as a checkpoint where you can review and prepare changes before committing them to the repository.
Approach 1: Using the git add command with the dot(.) notation:
Step 1: Create a project or folder so all our files will be there. Put all your files there to add on git.
For creating a folder use command- mkdir folder-name
For creating a file use command- touch file-name
Folder Structure: Create a folder similar to that.

Step 2: Initialize git to that project root or folder.
git init

Step 3: Add all files using dot(.) to git.
git add .
And make a commit immediately
git commit -m "added all files"

Step 4: To see the log of your added file, just run this command
git log
And log look likes this:

Approach 2: Using the git add command with the --all or -A flag:
Step 1: Make some changes to all files so that turned into modified state, if a file modified then 'M' will be shown right side.

Step 2: To know the status of all files, just run this command.
git status
And you will see this.

Step 3: To add all files using --all or -A flag, run following command on terminal.
git add --all OR
git add -A
and then make a commit.
git commit -m "added all modified files"

Now we can check git log.

Approach 3: Adding all files by extension.
In some cases, you may be interested in adding all files that have a specific extension : *.txt or *.js for example.
To add all files having a specific extension, you have to use the “git add” command followed by a wilcard and the extension to add.
git add *.txt
git add *.js
Let's say, we have two js files, and we want to add both files to git, then follow these command.

In this way, We can easily add all files to git.
Similar Reads
How to Remove Added Files in Git? In version control, Git is a powerful tool that helps developers manage and track changes to their code. One common operation in Git is merging branches. However, there are times when you might need to revert a merge commit, either because it introduced issues or was done by mistake. This article wi
3 min read
How to Add Empty Folder in Git? Maintaining directory structure in a Git repository often requires the addition of empty folders. While Git doesn't track empty folders directly, there are several approaches to accomplish this. In this article, we'll explore one of the most commonly used approaches, which involves using a placehold
1 min read
How to list All Files in a Commit in Git? Working with Git, it's often essential to inspect the contents of your commits. Whether you need to review changes, debug issues, or understand the history of your project, knowing how to list all files in a commit is a fundamental skill. In this article, weâll walk you through the steps to list all
3 min read
How to Ignore a File in Git? In this article, we are going to discuss how to ignore files in Git. Essentially, you can ignore files by specifying them in the ".gitignore" file. Moreover, you can also ignore directories using this method. Throughout this article, we'll cover everything from creating a GitHub account to setting u
3 min read
How to Delete Untracked Files in Git? Git is a powerful version control system widely used in software development for tracking changes in source code. While working with Git, you might find yourself in a situation where you have untracked filesâfiles that are not yet committed to the repository. Over time, these untracked files can clu
3 min read