繁体   English   中英

在回购子目录之间移动文件后,使用Git add --all

[英]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. *,因此可以执行以下操作之一:

  1. 从存储库的根目录运行git add --all
  2. 运行git add --all :/ :/路径是一个特殊的符号,表示“存储库的根目录”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM