[英]Using Git add --all after moving files between repo subdirectories
在我的一個Git倉庫中(我在Mac上使用的是Git 1.9.3),我已經將一些文件從根目錄移到了一個子目錄中。 正如我期望的那樣,當我運行git status
(在目標子目錄中)時,它將移動的文件顯示為從根目錄中deleted
,而新添加的文件顯示為未跟蹤的文件到子目錄中。 我應該做git add --all
來記錄更改,但是我從Git收到以下消息:
$ git add --all
warning: The behavior of 'git add --all (or -A)' with no path argument from a subdirectory of the tree will change in Git 2.0 and should not be used anymore.
To add content for the whole tree, run:
git add --all :/
(or git add -A :/)
To restrict the command to the current directory, run:
git add --all .
(or git add -A .)
With the current Git version, the command is restricted to the current directory.
在記錄移動文件方面,這兩者與工作樹有什么區別?在這種情況下,最佳選擇是什么?
移動或刪除文件時,最好使用git的本機工具。
這將從git存儲庫中刪除文件:
git rm [path]
這將使您將文件從oldpath
移至newpath
,並同時保留這些文件上的所有git歷史記錄
git mv [oldpath] [newpath]
在添加文件時,通常使用以下命令:
git status
git add *
git commit -m "message"
git push
Status使我可以檢查要添加的文件。如果要添加所有文件,可以使用*
,否則將鍵入它們的單獨路徑。
至於收到的錯誤消息,可能是因為您將它們移到了git以前不知道的子目錄中(即,您剛剛創建了它)
在git 2.0中, git add --all
的行為已更改。 在git <2.0中,它只是將文件添加到當前目錄中。 從2.0開始,它將每個文件添加到工作樹中。 消息只是在通知您此更改。
由於您正在運行git 1. *,因此可以執行以下操作之一:
git add --all
。 git add --all :/
。 :/
路徑是一個特殊的符號,表示“存儲庫的根目錄”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.