我正在尝试使用git管理我的 neovim 的 init.vim 。 我想忽略除 I'm trying to manage my neovim's init.vim with git.
I want to ignore everything except the init.vim in the same folder as the .gitignoreand one kalisi.vim in the directory / bundle / vim-airline / autoload / airline / themes / 这是我当前的 .gitignore : This is my current .gitignore: 我对此的看法: 忽略所有内容: * 除此 .gitignore : !. gitgnore init.vim 在同一目录中:!init.vim 也不要忽略文件夹 bundle :!bundle 但是其中的所有内容: bundle / * But everything in it: bundle/* 除了文件夹 vim-airline :!vim-airline 我想你明白了... 但是如果我执行 git状态现在仅获得 bundle / 作为未跟踪文件。我不应该得到 kalisi.vim 或 bundle / vim-airline / autoload / airline / themes / kalisi.vim ? But if I execute git status now only get bundle/ as untracked file. Should't I get kalisi.vim or bundle/vim-airline/autoload/airline/themes/kalisi.vim? 我希望能有一种更优雅的坦率方式。我还听说过要在目录中放置多个 .gitignore ,但是子目录都是具有自己的 .gitignore ,这将产生大量工作,而只是不忽略正确的 .gitignore 。 I'm hoping for a more elegant way to be honest. I also heard about placing multiple .gitignore's in the directories, but the subdirectories are all projects with it's own .gitignore and this would create a huge amount of work to only not-ignore the right .gitignore. 我希望有人知道该怎么做,目前看来好像跟踪了 bundle / 目录,但不是我想要的内容... I hope someone has an idea what to do, currently it just seems like the bundle/ directory is tracked, but not the content I want... 正如我在 如何将文件中没有点的文件(所有无扩展名的文件)添加到gitignore文件中?,使用要记住一个规则。 gitignore : 无法重新-包括文件(如果排除该文件的父目录)。 ( † ) ( † :除非在git 2.7+中满足某些条件,否则 It is not possible to re-include a file if a parent directory of that file is excluded. (†)
(†: unless certain conditions are met in git 2.7+) 这意味着,当您排除所有内容时(' * '),您必须先将文件夹白名单(' / ** / '),然后才能将文件白名单。 That means, when you exclude everything ('*'), you have to white-list folders ('/**/'), before being able to white-list files. OP LastSecondsToLive 实际上采用了一种更简单的方法: The OP LastSecondsToLive actually took a simpler approach: 我使用 bundle / vim-airline / autoload / airline / themes / kalisi.vim 创建了一个提交我将 .gitignore 切换回: *!.gitinore!init.vim 忽略所有内容,但是由于 bundle / vim-airline / autoload / airline / themes / kalisi.vim 已被跟踪,更改将在f中被跟踪未来
I created a commit with bundle/vim-airline/autoload/airline/themes/kalisi.vim then I switched my .gitignore back to:* !.gitinore !init.vim to ignore everything, but since bundle/vim-airline/autoload/airline/themes/kalisi.vim is already tracked, changes will get tracked in the future.
更多推荐
Git:子目录中的.gitignore
发布评论