Created
January 19, 2023 05:53
-
-
Save bendog/25f13cf83ef0db283dc656cc58a5c7d7 to your computer and use it in GitHub Desktop.
Revisions
-
bendog created this gist
Jan 19, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ # Remove .pyc files from your Python project git repo. Here are a collection of command line arguments, which will help you fix your issues with .pyc files. ## 1. Prepare for your change Go to your project root, the folder which is the base of your git repo. Make sure your project is up to date with your remote, run `git fetch` Make sure you are on your main branch, run `git checkout main` Make sure your local branch is up to date, run `git pull` ## 2. Update your .gitignore Update your git ignore, add these lines to the `.gitignore` file in your project root. (Don't include the ... those are to signify there may be existing content which you do not remove.) ``` ... # Python temp files __pycache__/ *.py[cod] *$py.class ... ``` ## 3. Remove the pyc files which have already been stored. Remove .pyc files using `git rm -f *.pyc` Commit the changes `git commit -am 'update to remove all pyc files'` Push your update `git push` ## 4. Update your other branches Update your other branches by following this process. select your branch, run `git checkout <branch name>` where branch name is the name of your branch (do not include the < and > ) check your branch is up to date, run `git pull` merge in your changes from main, run `git merge main` remove your pyc files, run `git rm -f *.pyc` commit the changes with `git commit --no-edit` check your repo is happy with `git status` if happy, push your changes `git push` repeat this for each branch you need to fix.