2017-07-25 152 views
0

我有我的Git bash主目录在版本控制下。我使用的是白名单(不顾一切除了...):无法在git仓库中取消配置ssh配置

$ cat .gitignore 
# Ignore all the things 
* 

# But not these (with exceptions) 
!*.bash_aliases 
!*.bash_profile 
!*.bashrc 
!*.drush/ 
!*.drush/* 
.drush/cache 
!.gitconfig 
!.gitignore 
!.gitalias 
!*.minttyrc 
!*.vim/ 
!*.vim/* 
.vim/.netrwhist 
!*.vimrc 

我想将.ssh/config添加到例外,但我还没有似乎已经得到语法正确。

$ ls .ssh/config 
.ssh/config 

我有这行我.gitignore

$ git diff 
diff --git a/.gitignore b/.gitignore 
index 22b3a79..b84bcd3 100644 
--- a/.gitignore 
+++ b/.gitignore 
@@ -12,6 +12,7 @@ 
!.gitignore 
!.gitalias 
!*.minttyrc 
+!.ssh/config 
!*.vim/ 
!*.vim/* 
.vim/.netrwhist 

但是它并没有被不可忽视:

~ (master) 
$ git status 
Changes not staged for commit: 

     modified: .gitignore 

no changes added to commit (use "git add" and/or "git commit -a") 

中的.gitignore在其他的东西语法来看,我试过这个:

$ git diff 
diff --git a/.gitignore b/.gitignore 
index 22b3a79..659d7be 100644 
--- a/.gitignore 
+++ b/.gitignore 
@@ -12,6 +12,7 @@ 
!.gitignore 
!.gitalias 
!*.minttyrc 
+!*.ssh/config 
!*.vim/ 
!*.vim/* 
.vim/.netrwhist 

无济于事:

$ git status 
Changes not staged for commit: 

     modified: .gitignore 

no changes added to commit (use "git add" and/or "git commit -a") 

什么是增加.ssh/config.gitignore异常的语法?

+0

可能的复制[.gitignore排除文件夹,但包含特定的子文件夹](https://stackoverflow.com/questions/5533 050/gitignore - 排除文件夹 - 丁包括特异性-子目录) – phd

回答

0

都会响起jingx的回答,我添加了这些行:

!*.ssh/ 
!*.ssh/config 

而且似乎已经奏效:

$ git add .gitignore 

$ git status 
Changes to be committed: 

     modified: .gitignore 
     new file: .ssh/config 

$ git add .ssh/known_hosts 
The following paths are ignored by one of your .gitignore files: 
.ssh/known_hosts 
Use -f if you really want to add them. 
1

git help ignore

这是不可能再有一个文件,如果该文件的父目录中排除。

因此,尝试添加:

!.ssh/