git add从内部目录使用时不添加更改

时间:2019-04-05 08:00:08

标签: git

我在projectdir>subdir>subsubdir内有以下目录.gitprojectdir文件夹

当我从git add .subsubdir时,projectdir内部的更改不会添加到Changes to be committed:

$ git status  
On branch master
Your branch is up to date with 'basicdjango/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   ../../.gitignore
    new file:   .env.example
    modified:   settings.py

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:   ../../.gitignore

所以我如何添加更改直到projectdir

1 个答案:

答案 0 :(得分:1)

... vector <Individual> getIndividual() { return this->population; } ... private: vector <Individual> population; 是“当前目录中的所有内容”(及其子目录中的递归内容)的语法。

所以您可以:

  • 在执行.之前移至上一级目录。由于避免这个问题似乎是您提出问题的根源,所以我们就跳过此选项。

  • 做同样的事情,但是为您的添加使用别名来简化此过程,在其之前嵌入cd。不过,我不太确定推荐这个,因为它可能有助于养成懒惰的习惯,同时又有潜在的危险。

  • 避免每次使用add。这是一个方便的工具,但在许多情况下仅需几个文件或目录就不需要。 (并且仅使用此快捷方式可能会导致忽略索引的存在,这可能不是一个好习惯)

  • 使用git add .来添加每个文件,并具有与上述相同的警告。 (请注意旧的git版本,其行为与git add -A相同)

相关问题