top of page
Search

.git out! ...or just .gitignore

  • Writer: Andrea Osika
    Andrea Osika
  • Oct 26, 2020
  • 3 min read

Updated: Oct 26, 2020

I recently completed an intensive data science program where I learned to code, a bunch of calculus, and other complex maths behind the algorithms involved in machine learning and artificial intelligence along with implementing additional packages for data collection, assimilation, and analysis for classification and/or prediction. It was a lot. Another tool I learned a little about was Github. It's a place to collaborate and share coding work on repos and the main solution is version control - meaning if you 'break' your code, or make a mistake, you can roll back to a prior version. Fantastic, right?


Except when there are things on your repo that you don't want - like:

  • credentials (username/passwords)

  • application files

  • logs

...basically, anything not used by the project, or the team you are sharing the project with or it's a file generated by another process.


Since the model for learning in this course was via applying skill were reviewed, and then I addressed other files by adding them to the .gitignore files. cat a pretty rapid pace and completed several projects to practice some of my new-found skills. At the end of the course, looking back at my work I was proud - ish. I wanted to share my projects to demonstrate what I learned, but... my repos were a little messy.


I began cleaning them up - files were organized to subfolders, readmes were edited and formatted, and then I addressed other files by adding them to the .gitignore files. .gitignore files are a great place for everything you need for your project but are not additive for anyone taking a look. It's probably best to just make them at the beginning of a project, but since I was new I honestly didn't know yet.


You can create a .gitignore file when creating a new repo:


ree

or if you want to add it in your console you can navigate to the folder/repo you'd like to add it to:


cd project_repo

then add the folder:


touch .gitignore

Once you've created your file you can open it up in a sublime or any other text editor and tell it to what add buy simply adding the files there:


.DS_store
.ipynb_checkpoints
test.csv
test_labels.csv
train.csv.learn
debug.log

It helps to make notes to yourself or others looking in the .gitignore - a more exhaustive, descriptive .gitignore would look like this:


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json


Another shortcut I've recently learned is a really quick way to add files without navigating to text editors (I'm a nut for efficiency):


echo 'file_name' >> .gitignore

Just make sure to use >> instead of > OR you'll simply overwrite the existing contents.


At any rate, I hope this post helps in cleaning and organizing, and ignoring the noise in your repos.


Happy Giting!




 
 
 

Comments


I Sometimes Send Newsletters

Thanks for submitting!

© 2019 by Andrea Osika. Proudly created with Wix.com.

bottom of page