1.10. Gitignore files¶
Your analysis will create many files that you might not want to sync to the remote repo on GitHub.com. The remote repo is “public” facing, so the goal is to have a clean remote repo without miscellaneous files.
Common versions of files you might not want on the remote repo:
temporary data files (such as mid point saves, data files you examined to check)
So how do we prevent git from syncing these files? The
1.10.1. How to create and edit a gitignore file¶
There are several ways to create one:
When you create a repo, select to add a gitignore file. I usually pick the python template option.
You can add it later on github or on your computer. The file is a simple text file and should be named
In GitHub desktop, choose the “Repository” menu, then “Repository settings”, then “ignored files” and type in what you’ll ignore.
Editting it: Any text editor!
Each line lists a file(s) or folder(s) that shouldn’t be tracked. Wildcards are allowed. For example,
should prevent the checkpoints Jupyter Lab makes from being synced.
1.10.3. I have a file in gitignore, but it’s on the remote repo!¶
That’s because it was already on the remote repo when you added it to the gitignore; The gitignore file simply tells git to “not sync” those files any more. It doesn’t mean “delete these files from the remote repo”.
There are a few ways to delete the extra files in the remote repo. The simplest: Go to the repo on Github.com and delete them individually.
If you are comfortable running some git commands, you can do it programmatically:
gt rm -r --cached . git add . git commit -m 'Removed all files that are in the .gitignore' git push origin master
I suggest making a backup copy of the folder on your computer before doing that until you confirm it worked as you intended.