Git

How to Add All New Files in the Git Repository?

When working on any development project, it is most common for them to create new files in the working area. Then, they track to the staging index and update the Git repository by committing all changes. The β€œgit add .” command can be used for this particular purpose.

This guide will provide the method for adding all newly generated Git repository files.

How to Add All New Files in the Git Repository?

Follow the below-given to push all files in the Git repository:

  • Navigate to the particular Git repository.
  • Use the β€œecho” command to create new files.
  • Track all newly generated files to the staging index.
  • Push all files to the Git repository through the β€œgit commit -m” command.

Step 1: Go to Desired Repository
First, run the following command and redirect to the Git local repository:

$ cd "C:\Users\nazma\Git\test_dir"

Step 2: Generate and Update File
Then, generate and update the new file by executing the β€œecho” command:

$ echo "my first file" >> "file1.txt"

Step 3: Create and Modify New File
To create and modify another file with the help of the following command:

$ echo "my second file" >> "file2.txt"

Step 4: Make New File and Add Data
Similarly, execute the provided command to make a new file and add data immediately:

$ echo "my third file" >> "file3.txt"

Step 5: Push All Changes
After that, push all changes from a staging area to the Git repository by running the below-given command:

$ git add .

Step 6: Ensure All Pushed Files
Use the β€œgit status .” command to verify whether all the newly created files are added to the staging area or not:

$ git status .

According to the below-given output, all working area changes are moved to the staging area:

Step 7: Add Files Into Git Repository
Lastly, move all added files from the tracking area to the local Git repository by running the β€œgit commit” command:

$ git commit -m "new files are added"

According to the below given-output, all files are successfully pushed to the repository:

We have provided the easiest way to add all newly created files in the Git repository.

Conclusion

To push all files in the Git repository, first, redirect to the particular Git repository and ssuse the β€œecho” command to create new files and update them immediately. Next, execute the β€œgit add .” command. Lastly, check the current status of the Git repository and run the β€œgit commit” command along with the β€œ-m” option. This guide demonstrated the process of adding all newly generated Git repository files.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.