As your project starts to become bigger and messy, organize it by not pushing irrelevant files and folders.
Consider the image below.
There is a folder that I don’t care to upload to the repository. That folder is…you guessed it! “Useless_Folder”. Let’s say this folder is where I keep my personal notes on the project, or where I store all my dank memes about the project that I don’t want my partners to see. When I push updates, I certainly don’t want to push anything and everything.
Create a new text file and name it “.gitignore”. A warning might pop up, press Ok through it. Open it and type the following:
The “.idea” will ignore the “.idea” folder (this is typical because it relates to your specific IDE)
The “Useless_Folder/” will ignore that folder
The “*csv” will ignore any file type with the “.csv” file extension
git add, commit, and push this new “.gitignore” file.
Consider the following code:
I create a new csv file called “new_file”
I create a dictionary called “dataSet1”
I convert the dictionary to a pandas DataFrame called “df”
I write the df to the csv file
As seen in the first image, after running this program I have this new csv file in my root folder path. This is cool, but there is no need to push this to the repository because it will be created whenever someone runs this program; they don’t need to download it.
Now, type “git status”. You will notice that none of the files and folders we ignored show up as ready to be committed. When you push your project, you will notice that these files are not in your Github repository. Don’t ignore the .gitignore and your project will stay clean!