A script that pushes local project folders to GitHub as private repos, skipping ones already there.
- Python — check "Add Python to PATH" during installation
- Git
- GitHub CLI
- Install all three requirements above
- Open your terminal and run
gh auth login - Select GitHub.com
- Select HTTPS
- Select Login with a web browser
- Enter the one-time code shown in your terminal at github.com/login/device
- Click Authorize GitHub CLI
Before running, open sync-repos.py and update parent_folders to your own folder paths:
# Replace these with your own paths
parent_folders = [
"C:/Users/YourUsername/your-folder",
"C:/Users/YourUsername/another-folder"
]For example if your name is John and your projects are in my-code:
parent_folders = [
"C:/Users/John/my-code/web-dev",
"C:/Users/John/my-code/python"
]- Update
parent_foldersas shown above - Right-click
sync-repos.pyand open with python
Any new folders get pushed as private repos. Already existing ones are skipped. Works for both MAC and WIN users aswell as Linux
Important
The script uploads the grandchildren of the parent folder as a subfolder of their parent folder, not as a separate folder. e.g. if the parent is "C:/Users/John/my-code/python" and there is "C:/Users/John/my-code/python/data-structure/processed-data" then processed-data will upload as the child of data-structure.
Important
New files or folders is what get synced, a change of code in a particular file won't be synchronized.
Tip
I wouldn't reccomend this for a long term use as it's good to have README's and learn git but if you have too many local projects and shipping them all seems tedious (which it is) this would be your best friend for a while and you'd also be able to synchronize your code with github as opposed to only comitting new files or folders.