【发布时间】:2018-05-19 20:13:34
【问题描述】:
直到现在,我还以为我对 .gitignore 文件的处理非常好。我正在尝试在 Git 存储库中包含仅以下文件:
- .gitignore
- .bashrc
- .vimrc
- .vim/(此目录中的所有内容)
我已经阅读了 StackOverflow 上的其他几个答案(How do I ignore files in a directory in Git?、Git ignore sub folders 和 Is there a way to tell git to only include certain files instead of ignoring certain files?)。但是,我似乎无法正确获取我的 .gitignore 文件。这是我目前在.gitignore 文件中的内容:
*
.*
!.gitignore
!.bashrc*
!.vimrc
!.vim/
在我运行 git init; git add .; git status 后,repo 包含:
$ git init; git add .; git status
Initialized empty Git repository in /home/username/.git/
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .bashrc
new file: .gitignore
new file: .vimrc
我尝试了我的.gitignore 文件的最后一行的变化,但无济于事。谁能发现我的错误?
编辑
我正在尝试找到一种解决方案,它仅修改.gitignore 文件。
【问题讨论】:
-
不,我的
.vim/目录包含一个名为bundle的子目录。bundle文件夹下有很多文件和目录。 “输出似乎正确”是什么意思?我的目标是包含.vim/文件夹及其中的所有内容。 -
你可以使用
-force标志:git add -f .vim -
我尝试了
!/.vim,结果相同。我可以使用-force标志,但我试图通过仅修改.gitignore文件来找到可行的解决方案。我会更新问题以反映这一点。