BACK_TO_LOGS// STEP_9_OF_10
HANDBOOK_GUIDE2026-06-29

OptiCrop: Smart Agricultural Production Optimization Engine ML Guide

By Rayan Syed
45 min read

Part 9: Connecting to GitHub & Pushing Your Code

Now that your machine learning model is trained and your web application is fully tested locally, you are ready to back up your codebase to GitHub.

9.1 Connecting a Local Folder to GitHub

Open your project terminal and run these commands sequentially to initialize and link your repository:

  1. Initialize Git locally: Run git init. This creates a hidden .git folder inside your project directory to start tracking changes.
  2. Create a .gitignore file: To avoid uploading unnecessary files (like models, dataset ZIPs, or cache folders), create a file named .gitignore in your project root and add:
    __pycache__/
    models/
    venv/
    .ipynb_checkpoints/
    
  3. Stage your files: Run git add . to prepare all code, template, and document assets for tracking.
  4. Commit files: Run git commit -m "feat: complete OptiCrop agricultural engine" to save your local snapshot.
  5. Rename main branch: Run git branch -M main to establish your primary branch.
  6. Link to GitHub repository: Create a repository on GitHub, copy its URL, and run:
    git remote add origin https://github.com/yourusername/opticrop.git
    
  7. Push code to GitHub: Run git push -u origin main to upload your codebase remote.