Home > Development Tools > git > How to add a directory in git

How to add a directory in git

WBOY
Release: 2022-01-14 15:04:42
Original
9821 people have browsed it

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.

How to add a directory in git

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] ...
Copy after login

Add the specified directory to the staging area, including subdirectories:

git add [dir]
Copy after login

Add all files in the current directory To the staging area:

git add .
Copy after login

In the following example, we add two files:

How to add a directory in git

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
Copy after login

Now we execute git status again, and we can see that these two files have been added.

How to add a directory in git

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!

Related labels:
git
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template