git add 命令用于把修改后的文件添加到暫存區(qū)。
git add [file1] [file2] ...
git add [dir]
git add .
以下范例我們添加兩個(gè)文件:
$ touch README # 創(chuàng)建文件 README $ touch hello.php # 創(chuàng)建文件 hello.php $ ls README hello.php $ git status -s ?? README ?? hello.php $
git status 命令用于查看項(xiàng)目的當(dāng)前狀態(tài)。
接下來(lái)我們執(zhí)行 git add 命令來(lái)添加文件:
$ git add README hello.php
再次執(zhí)行 git status,就可以看到這兩個(gè)文件已經(jīng)添加。
$ git status -s A README A hello.php
在項(xiàng)目中,我們經(jīng)常使用 git add . 命令來(lái)添加新的文件或者修改過(guò)的文件。