2017-07-25 50 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/