Git Add File to Repository

Git Add File to Repository

 Git Add File to Repository

Use the git add command to add new files to the local git repository. This command will not add ignored files by default, also skip files silently found in the recursive run. The command will throw an error for the files explicitly specified on the command line.


git add [FILENAMES]

Dry run for Git Add

This option doesn’t actually add the file(s). You can use -n or --dry-run to test files if they exist and/or will be ignored with git add command.

git add . --dry-run

Examples of Git Add Files

You can also specify filenames with git add c a mmand to add the specific file. Use the following example command to add README by specifying names.

git add index.html README

Also, you can use wildcard names to add files. For example, add all the files with the .txt extension from the Documents directory.

git add Documents/\*.txt

You can also specify dot (.) to add all the files, directories, and sub-directories. This is useful while adding multiple files.

git add .

Post a Comment