2017-07-25 4 views
0

J'ai mon répertoire personnel Git bash sous contrôle de version. J'utilise une liste blanche (ignorer tout sauf ...):Impossible de ne pas ignorer ssh config dans git repo

$ 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 

Je veux ajouter le .ssh/config des exceptions, mais je ne l'ai pas semblé avoir obtenu la syntaxe correcte.

$ ls .ssh/config 
.ssh/config 

J'ai cette ligne dans mon .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 

Cependant, il n'a pas été unignored:

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

     modified: .gitignore 

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

regardant la syntaxe d'autres choses dans le .gitignore, j'ai essayé ceci:

$ 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 

en vain:

$ git status 
Changes not staged for commit: 

     modified: .gitignore 

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

Quelle est la syntaxe pour ajouter .ssh/config comme une exception dans .gitignore?

+0

double possible de [.gitignore exclut le dossier mais inclut un sous-dossier spécifique] (https://stackoverflow.com/questions/5533 050/gitignore-exclude-folder-but-include-spécifique-sous-dossier) – phd

Répondre

0

Allant au large de la réponse de jingx, j'ai ajouté ces lignes:

!*.ssh/ 
!*.ssh/config 

Et il semble avoir travaillé:

$ 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:

Il est impossible de ré-inclure un fichier si un répertoire parent de ce fichier est exclu.

Donc, essayez d'ajouter:

!.ssh/