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