This post will be about adding .gitignore and requirements.txt files.
Unlike 5 previous posts, it is not on the JustDjango Learn website free tutorial.
However, since I need to push to git and this project will be in public, I need those two files.
Still, JustDjango Learn website explains easily, so recommend to go to watch their videos.
1. .gitignore
- .gitignore file specifies intentionally untracked files that git should ignore.
- files already tracked by git are not affected
- So, it is better to have and update gitignore file before.
- of course, there are ways to untrack tracked files.
- We can create .gitignore file easily on toptal site. https://www.toptal.com/developers/gitignore
- Create new file under project root folder name .gitignore
- copy paste the above txt generated from toptal site.
2. requirements.txt
- why need requirements.txt file even the code working fine in my local?
- here is the exact answer on this article. https://boscacci.medium.com/why-and-how-to-make-a-requirements-txt-f329c685181e
- how to create the requirements.txt file?
- activate your virtualenv
- type the command below
pip freeze > requirements.txt
- you will see the requirements.txt file is automatically generated.
- But I see a lot of projects have multiple (requirements).txt files.
- This is because for multiple situations. development in local, to test, to deploy.
- This site has good explanation and how to. https://riptutorial.com/django/example/8561/using-multiple-requirements-files