I have my Git bash home directory under version control. I'm using a whitelist (ignore everything except ...):
$ 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
I want to add the .ssh/config
to the exceptions, but I haven't seemed to have gotten the syntax correct.
$ ls .ssh/config
.ssh/config
I have this line in my .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
However it hasn't been unignored:
~ (master)
$ git status
Changes not staged for commit:
modified: .gitignore
no changes added to commit (use "git add" and/or "git commit -a")
Looking at syntax of other things in the .gitignore, I tried this:
$ 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
to no avail:
$ git status
Changes not staged for commit:
modified: .gitignore
no changes added to commit (use "git add" and/or "git commit -a")
What is the syntax to add .ssh/config
as an exception in .gitignore
?
Going off of jingx's answer, I added these lines:
!*.ssh/
!*.ssh/config
And it seems to have worked:
$ 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.