How to Add files in GIT


Add single File

Use the git add command followed by the file name to add the file to the staging area:

egit add filename.txt

Add all files in the current directory:

You can also add multiple files at once by using the . (dot) operator to add all files in the current directory:

git add .

Add files by extension in Git

To add files by extension in Git, you can use the following command:

git add *.ext

Replace ext with the file extension you want to add. This command will add all files with the specified extension to the staging area.

For example, to add all files with .txt extension in the current directory and its subdirectories, you can use the following command:

git add '*.txt'

Add files to Git using wildcards

  1. To add all files with a specific extension, for example, all .txt files in the current directory and its subdirectories:
git add '*.txt'
  1. To add all files in the current directory and its subdirectories that have a certain prefix, for example, all files that start with example_:
git add 'example_*'
  1. To add all files in the current directory and its subdirectories that match a certain pattern, for example, all files that contain the word test in their name:
git add '*test*'