2014-03-27 18 views
2

我知道如何添加並提交一個文件:如何在git的承諾許多文件

git add [file name]git commit -m

但怎麼樣,如果我在不同的目錄許多文件。怎樣才能做到這一點?謝謝。

回答

2

您可以在addcommit命令中列出所有這些文件。例如:

git add [file name] [file name] [file name] ...

git commit [file name] [file name] [file name] ... -m 'commit message'

7

首先將文件添加到舞臺上,例如:

git add file1 file2 file3 file4 

或者整個目錄:

git add directory1/ directory2/ 

當所有都在上演,你可以一次提交所有這些:

git commit -m "All at once" 
2

的Git的Bash支持使用它添加和許多其他命令的正則表達式。所以說,例如,你想添加目錄中的所有Java文件,你可以不喜歡

git add /path/to/dir/*.java 

一如既往可以運行git add --help找出更多的用法和選項的git優惠。

+1

我不知道通配符等是由於git支持還是隻是一個BASH功能。 –

+0

非常真實。謝謝你指出。 – 9er

2

添加上@Brovoker答案的頂部,有很多種方法來實現:

舉幾個例子:

git add .將上演從當前目錄一切:這不會上演文件已被刪除。

git add -A將階段的一切,包括刪除的文件。

你甚至可以使用通配符同時加入git add directory/my*將在開始my

欲瞭解更多信息,你應該籤更多選項man git-addman git-commit目錄添加的所有文件。