Automatically ignore __pycache__ files when using git push

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 commitcommand, these files will be submitted to the cache (Stage/Index) at the same time, and push origin masterwill inevitably be submitted to github in the future

  • need:

    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 invalid

  • solution:

    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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325590680&siteId=291194637
Recommended