Ignore __pycache__ files when using .gitignore file push
Problem Description:
When using git push for a local project, some files do not need to be pushed to github, but when using the
git add or commit
command, these files will be submitted to the cache (Stage/Index) at the same time, andpush origin master
will inevitably be submitted to github in the futureneed:
When git push, ignore custom files (such as:
__pycache__
configuration files with database passwords, etc.)solve:
Use the .gitignore file that comes with git to customize the files to be ignored
method:
sudo vim .gitignore
# python *.py[cod]
Notice:
.gitignore files can only work on Untracked Files, that is, those files that have never been recorded by Git (files that have never been added and committed since they were added).
If the files have been recorded by Git, then .gitignore is completely for them invalidsolution:
In the local workspace, delete the unnecessary files first and push them to the remote warehouse. When the file is executed next time, git add is required. When the
__pycache__
file is found to have been ignored and pushed
Recommendation:
github has already configured the .ignore file, which can be downloaded and used