I have my dot files in Github publicly.
This means that I have only a few files at my Home shared with others.
The disadvantage of sharing, for instance, .bashrc with others is that I need to be careful not adding confidential data to Github.
I run
git status
I get a long list of untracked files.
I found out that apparently the only way to get rid of them them is by running
git clean -df
This would remove my private files which I do not want to.
How can you remove my private files from Git’s status without removing my private files at my Home?
You can ask Git to ignore given untracked files using gitignore mechanism:
.gitignorefile in current directory.gitignorefile in top directory of your repositoryinfo/excludefile in $GIT_DIR (in.gitrepository database)core.excludesFileconfig variable to e.g. “/home/user/.gitignore”(currently Git does not expand environmental variables such as $HOME or ‘~’ in paths)
For your situation it would be probably best to use ‘.git/info/exclude’, because this way name of ignored file would be not visible to others, contrary to the situation where you accidentally commit
.gitignorefile, or you are forced to have it in repository. Usually.gitignore(versioned and distributed) is about ignoring e.g. generated files, whileinfo/exclude(orcode.excludesFile) is about ignoring site-specific files, like backup files of your editor.