Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

I made changes to two files in a different directory, How can I add the two files for a single commit. can I do like, add the first, then change the directory to the second file and add the second file finally do the commit. Is this going to work?

1 Answer

+1 vote
by (62.9k points)

You can add all the files using the git add command like below for all the files you want to add, which will add all your files to the staging area, which means the files are ready to be committed.

git add file1.txt folder/file2.txt file3.txt file4.txt file5.txt

Now commit your files, the editions or addition made in the files will now be saved.

git commit file1.txt folder/file2.txt file3.txt -m "Some_message"

You will have added these files





to the staging area and then committed with the same message.




Note that files are added or committed in the same format.

by (19.7k points)
Thanks, finally now I know how to add two files for a single commit

Browse Categories