スポンサーリンク

カレントディレクトリ以下を再帰的にgit addする

git add . で、カレントディレクトリ以下を再帰的にgit addする方法です。
多数のファイルを新規作成したときに便利です。

下記のように、ファイルを新規作成します。

 $ touch file002.txt 
 $ mkdir dir001
 $ cd dir001/
 $ touch file003.txt 
 

git add . を実行します。

 $ git add .
 

サブディレクトリのファイルも新規登録されました。

 $ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   dir001/file003.txt
	new file:   file002.txt
 

スポンサーリンク

特定のディレクトリ以下を再帰的にgit addする

git add ディレクトリ の形式で、特定のディレクトリ以下を再帰的にgit addできます。

dir001ディレクトリ以下を更新したとします。

 $ cd dir001/
 $ echo "text" >>file003.txt 
 $ touch file004.txt 
 $ cd ..
 

git statusすると、
 $ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   dir001/file003.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	dir001/file004.txt

no changes added to commit (use "git add" and/or "git commit -a")
 

ir001ディレクトリ以下を再帰的にgit addします。
 $ git add dir001/
 

dir001ディレクトリ以下がgit addされているのが確認できます。
 $ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   dir001/file003.txt
	new file:   dir001/file004.txt

スポンサーリンク