Skip to content

Git Gitignore

Andrew Colbeck edited this page Feb 6, 2019 · 7 revisions

Create a gitignore file in a Repo

The .gitignore file must be placed in working directory. Create and open with Terminal:
touch .gitignore && open .gitignore

Patterns and OS recommended exclusions

https://www.gitignore.io/
https://help.github.com/articles/ignoring-files/
https://github.com/github/gitignore

Remove a file (.DS_Store) from local Repo

git rm --cached .DS_Store

Remove a Folder

git rm -r folder-name

Add a File to gitignore

echo "*.pyc" >> .gitignore
where "*' represents any character or array of chars.

Setup global gitignore file

MacOS
Create a Global gitignore file

This will tell Git to add .gitignore_global as the global gitignore file in your global git config.
git config --global core.excludesfile ~/.gitignore_global

Add to global gitignore file

Use ⌃OWrite Out to save changes, hit Enterto save changes to the highlighted file path name (as long as it matches).
sudo nano ~/.gitignore_global

Windows
Create a Global gitignore file

This will tell Git to add .gitignore_global as the global gitignore file in your global git config.
git config --global core.excludesfile ~/.gitignore_global

Add to global gitignore file

Open and edit the .gitignore_global in your home directory using cmd
notepad %USERPROFILE%\.gitignore_global

Clone this wiki locally