2017-02-09 145 views
1

下面我都試過,但似乎不工作如何在一個命令中使用git提交修改過的文件和文件夾?

$ git commit -m "Changes" vendor/* dev/* .htaccess composer.json 

錯誤

error: pathspec 'vendor/cweagans' did not match any file(s) known to git. 
error: pathspec 'vendor/magefan' did not match any file(s) known to git. 
error: pathspec 'vendor/phpoffice' did not match any file(s) known to git. 

我有修改過的文件的多個文件夾。

如何提交所有使用一個命令?

回答

0

在使用git commit之前,使用git add命令向暫存區域添加新文件(或已更改)。

+0

從地方我需要更改推及於服務器需要拉。 'git add'會添加文件嗎?我修改了多個文件夾和單個文件中的文件,以及在 –

+1

問題中提到的問題。我不確定你在問什麼,或者你對git的工作方式感到困惑。 'add'和'commit'命令在_local_存儲庫上工作(請參閱https://www.atlassian.com/git/tutorials/saving-changes)。 Git'push'和'pull'與中央資料庫同步(https://www.atlassian.com/git/tutorials/syncing)。正如Greg所說,你使用'add'來告訴git你想'將一個文件提交給_local_存儲庫,並且當你認爲代碼已經準備好共享時,你可以使用push來移動已經提交的代碼直到中央存儲庫。 –

0

提交指定文件在一個命令與--include

$ git commit -m "Some commit message" --include <path1> <path2> <pathN> 

提交所有修改和刪除文件的一個命令--all

$ git commit -m "Some commit message" --all 

對於例如在你的問題--include看起來是這樣的:

$ git commit -m "Changes" --include vendor/* dev/* .htaccess composer.json 
相關問題