【问题标题】:"git add -all" command not add files under my GitRepository/.vim/subdir/sub-subdir“git add -all”命令不在我的 GitRepository/.vim/subdir/sub-subdir 下添加文件
【发布时间】:2016-09-25 04:50:49
【问题描述】:

我只想在我拥有的每台计算机上同步我的 .vim 文件夹。这些就是我为此目的所做的: 1. cp -r ~/.vim ~/GitRepository/ 2. cd ~/GitRepository 3. git add --all 4. 提交和推送。但是当我检查我的 github 时,这些文件应该在 /.vim/subdir/sub-subdir 下丢失了。那些子目录变成了空的。尽管我没有 .gitignore 文件,但link 中的建议对我没有帮助。

当我输入 git status 时。这些注释出现:

─➤  git status

On branch master
Your branch is up-to-date with 'origin/master'.

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)
  (commit or discard the untracked or modified content in submodules)

modified:   .vim/bundle/vim-snippets (modified content)
no changes added to commit (use "git add" and/or "git commit -a")

是什么导致这种情况发生?

=============== 第二次编辑============= 谢谢你们。 “git add -all”实际上错过了我拥有的点文件。但是,它解决不了我的问题。

这是我输入 git add .vim/ 后的内容

╰─➤  git status
On branch master
Your branch is up-to-date with 'origin/master'.

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

    new file:   .vim/.netrwhist
    new file:   .vim/.vimrc
    new file:   .vim/.ycm_extra_conf.py
    new file:   .vim/.ycm_extra_conf.pyc
    new file:   .vim/bundle/Vundle.vim
    new file:   .vim/bundle/YouCompleteMe
    new file:   .vim/bundle/ctrlp.vim
    new file:   .vim/bundle/molokai
    new file:   .vim/bundle/nerdtree
    new file:   .vim/bundle/tagbar
    new file:   .vim/bundle/ultisnips
    new file:   .vim/bundle/vim-airline
    new file:   .vim/bundle/vim-colorschemes
    new file:   .vim/bundle/vim-fugitive
    new file:   .vim/bundle/vim-json
    new file:   .vim/bundle/vim-snippets
    new file:   .vim/colors/molokai.vim
    new file:   .vim/colors/solarized.vim

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)
  (commit or discard the untracked or modified content in submodules)

    modified:   .vim/bundle/vim-snippets (modified content)

似乎 git 无法将这些识别为目录,为什么?

【问题讨论】:

标签: git vim


【解决方案1】:

add --all 不会添加隐藏文件或目录(即那些以点开头的)。您需要按名称显式添加它们(或至少像.* 这样的模式)。

(题外话,但可能有帮助:我使用homesick gem 来管理我的点文件。它可以自动执行您现在手动执行的许多操作。)

【讨论】:

  • 感谢您对想家的建议。但它需要更多的时间来了解。您能否描述更多关于“明确按名称”的信息?我应该按名称手动输入 git add 吗?
  • git add ~/GitRepository/.vim,如果我理解你的目录结构正确的话。
  • 是的,我完全按照你说的做。但问题仍然没有解决。我再次编辑了 Q&A,它显示除了 ~/GitRepository 下的一些点文件之外没有任何尊重。
【解决方案2】:

如果你想递归地添加一个目录和其中的所有文件,你必须在add命令中指定目录名。

$ git add directoryname

【讨论】:

  • 不,这是不正确的。可以使用add --all 添加目录,无需明确命名; 隐藏目录不能。
【解决方案3】:

您可以使用的最佳方法是:

 git add *

 git add <directory name>

【讨论】:

    【解决方案4】:

    最后,我找到了原因。我使用 vundle 来管理我的 vim 和 .vim/ 文件夹。因此,vundle 在每个“子目录”中都使用了 git 服务,并且在每个“子目录”中使用 .gitignore,它实际上忽略了“子目录”中的这些东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 2023-04-02
      • 2014-12-25
      相关资源
      最近更新 更多