Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How to add multiple files to Git at the same time -git add multiple files ?

Asked by Dylan Forsyth Apr 19, 2021 6.1K views 2 answers
Share

About this question

I am new to git. I have added new files ( a lot ) to the folder/project ( git local repository).

I went through online tutorials and forums and see I can do

     git commit -a

So I go to the base folder of the repository and do a

    sudo git commit -a

But then, some screens comes up and asks me to add a comment which I do. I do not know how to proceed or exit. I do not want to mess up so I did ctrl + Z and did not do anything.

Can you guys please outline the commands I need to use?

git commit -a 

or

git push

How git add multiple files ?

Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on Apr 26, 2024

To add multiple files to Git at the same time, you can use the git add command followed by the names or paths of the files you want to add. Here's how you can do it:

git add file1 file2 file3

 Replace file1, file2, and file3 with the actual names or paths of the files you want to add. You can add as many files as needed by separating them with spaces.

git add .

This command adds all untracked files and stages them for the next commit. However, be cautious when using git add . as it adds all untracked files, including those you might not want to commit.

After adding the files, remember to commit your changes using git commit. For example:

Alternatively, if you want to add all files within a specific directory and its subdirectories, you can use the following command:

This creates a new commit with the changes you've staged using git add.


Was this helpful?

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.