I am trying to make sure the contents of the .ssh directory do not get into the Git Repository:
executeS:~$ git diff --stat --cached origin/master
.gitignore | 7 ------
.ssh/.gitignore | 2 ++
.ssh/authorized_keys | 1 +
.ssh/id_rsa | 51 ++++++++++++++++++++++++++++++++++++++
.ssh/id_rsa.pub | 1 +
.ssh/known_hosts | 2 ++
.viminfo | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------
I then take them out as follows:
executeS:~$ git rm --cached .ssh/authorized_keys
rm '.ssh/authorized_keys'
executeS:~$ git rm --cached .ssh/id_rsa
rm '.ssh/id_rsa'
executeS:~$ git rm --cached .ssh/id_rsa.pub
rm '.ssh/id_rsa.pub'
executeS:~$ git rm --cached .ssh/known_hosts
I have the following .gitignore file
executeS:~/.ssh$ pwd
/home/dockcclubdjango/.ssh
executeS:~/.ssh$ cat .gitignore
.*
!/.gitignore
But then if I do, "git add . -A", I get waht I had in step 1 all over again. What can I do to make sure that .ssh NEVER gets into the repository?
You need also
/.ssh
line to your .gitignore
.ssh
from git and addition of the line to .gitignore
)Now git add -A
will not add it back (tested with Git 2.15.0)
Regarding second question ("What can I do to make sure that .ssh NEVER gets into the repository?"): .gitignore
does not prevent a file to be added to a repository. You can always add ignored file with git add -f path/to/file
.