Git common commands --- git add command

The general form of Git add is: git add [parameters] [--] <path>

Indicates that the code that needs to be submitted is added from the workspace to the staging area. For convenience, . is generally used to identify the path, and . represents the current directory.

 

1. git add .

The common saying on the Internet is to add modified files and untracked and newly added files to the staging area of ​​the git system, but not including deleted files.

But the actual test, git add . will also add the deleted file to the staging area.

 

There are a.txt and c.txt in the remote repository. At this point, a.txt was modified, c.txt was deleted, and a d.txt was added

 

Use the git add . command to submit to the staging area, and then check and

find that the deleted files are also in the staging area

 

2. git add -u .

-u == --update  means to add the modified and deleted files in the tracked files to the staging area, excluding newly added files.

 

Continue to the previous step:


3. git add -A .

-A == -all  means that all the modifications and deletions of tracked files and new untracked files are added to the staging area.




4. git add -i .

-i == - interactive Interactive mode.



 

4.1 revert subcommand

Indicates that files that have been added to the index library will be removed from the index library.

After executing this command, git will exemplify the list of files in the index repository. Then choose by numbers.

Entering "1" means that git will list the first file in the list of files in the index repository.

If we don't enter anything and press Enter, it will end the revert subcommand and return to the main command line of git add -i.

 

4.2 The update subcommand

Indicates that the tracked files are added to the index library.

 

4.3 add untracked subcommand

表示将还没被git管理的文件添加到索引库中。

 

4.4 diff子命令

表示比较索引库中文件和原版本的差异。

 

5. git add -h

查看帮助,使用git add --help可以查看更详细的内容

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326170369&siteId=291194637
Recommended