Home >Development Tools >git >How to add a directory in git
In git, you can use the add command to add a directory. The function of this command is to add the specified file or directory to the temporary storage area. The syntax is "git add folder/"; after adding the directory, you can use "git status" command to view the addition results.
The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.
How to add a directory in git
git add folder/ Add the entire folder and its contents
git add *.file Type Add all files of this file type in the directory
The git add command can add the file to the staging area.
Add one or more files to the staging area:
git add [file1] [file2] ...
Add the specified directory to the staging area, including subdirectories:
git add [dir]
Add all files in the current directory To the staging area:
git add .
In the following example, we add two files:
The git status command is used to view the current status of the project.
Next we execute the git add command to add files:
$ git add README hello.php
Now we execute git status again, and we can see that these two files have been added.
Recommended study: "Git Tutorial"
The above is the detailed content of How to add a directory in git. For more information, please follow other related articles on the PHP Chinese website!