mcmullenrich / PDICapstone1

2 stars 0 forks source link

Create a .gitignore file #4

Closed JnyJny closed 8 months ago

JnyJny commented 8 months ago

A .gitignore file is a file containing a list of file names and patterns that we would like git to automatically ignore when we check the status of a repo and complain when we try to add and commit these files.

When you first create a repo with GitHub, it will offer to add a .gitignore file for you based on the type of project your repo will house, see GitHub's Python .gitignore as an example.

In general, we only want to track files in the repo that are code or relevant metadata (data about data). One thing most people exclude automatically from their Python repos are any directory named __pycache__ which is created where Python caches compiled versions of your code. When you run your code, Python checks the cache to see if the cached version matches what you asked to run and uses it if there hasn't been any changes to your code.

To clean up the __pycache__ directory committed to your repo, you'll need to first remove it in your local directory, commit the removal and then add and commit the .gitignore file.

$ cd project_directory
$ git rm -rf __pycache__
$ git commit -m "Removed __pycache__ from repo"
$ vi .gitignore
$ git add .gitignore
$ git commit -m "Added gitignore for the project"
$ git push

I know you are using the VSCode source code interface, I just wanted to demonstrate the explicit order of operations.

JnyJny commented 8 months ago

Good work, we took care of this on our last call.