Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple files in git for a single commit?

Tags:

git

git-commit

I made changes to two files in 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 second file and add the second file finally do the commit. Is this going to work?

like image 946
Tumuluri V Datta Vamshi Avatar asked Aug 18 '15 14:08

Tumuluri V Datta Vamshi


1 Answers

You can add all the files using

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

And the commit your the files you wish to commit.

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

You will have added

  • file1.txt
  • folder/file2.txt
  • file3.txt
  • file4.txt

to staging area and then commited with the same message.

  • file1.txt
  • folder/file2.txt
  • file3.txt

Note that files are added or committed in the same format

like image 148
iamafasha Avatar answered Oct 30 '22 19:10

iamafasha