Setting up a Python Project with uv and Pushing to GitHub in VSCode

Created: 2025-03-11 16:09:53 | Last updated: 2025-09-30 22:59:12 | Status: Public

This guide walks through creating a Python project using uv init, then adding and committing it to GitHub using VSCode on Windows 11.

Prerequisites

  • Python installed on your system
  • VSCode installed with Git integration
  • GitHub account
  • Windows 11 operating system

Step 1: Install the ‘uv’ Tool

First, ensure you have the ‘uv’ tool installed:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
pip install uv

Step 2: Create a New Python Project

  1. Open your terminal in VSCode (Terminal > New Terminal)
  2. Navigate to where you want to create your project
  3. Run the ‘uv init’ command:
uv init Colors

This creates a directory called “Colors” with a basic Python project structure.

Step 3: Set up the Project

  1. Navigate into the project directory:
cd Colors
  1. Examine the created files (typically a pyproject.toml, src directory, etc.)

Step 4: Initialize Git Repository

  1. Initialize a Git repository:
git init
  1. Create a .gitignore file for Python:
# Create .gitignore file
echo "__pycache__/" > .gitignore
echo "*.py[cod]" >> .gitignore
echo "*$py.class" >> .gitignore
echo ".env" >> .gitignore
echo ".venv" >> .gitignore
echo "env/" >> .gitignore
echo "venv/" >> .gitignore
echo "ENV/" >> .gitignore
echo "env.bak/" >> .gitignore
echo "venv.bak/" >> .gitignore
echo "dist/" >> .gitignore
echo "build/" >> .gitignore
echo "*.egg-info/" >> .gitignore

Step 5: Create a GitHub Repository

  1. Open a web browser and go to GitHub
  2. Log in to your GitHub account
  3. Click the “+” button in the top-right corner and select “New repository”
  4. Name your repository “Colors”
  5. Add a description (optional)
  6. Choose whether to make it public or private
  7. Don’t initialize with a README, .gitignore, or license since we’re importing an existing repository
  8. Click “Create repository”
  1. In VSCode terminal, add the GitHub repository as a remote:
git remote add origin https://github.com/YOUR_USERNAME/Colors.git

Replace YOUR_USERNAME with your GitHub username.

git remote add origin https://github.com/ill13/Colors.git

Step 7: Stage and Commit Files

  1. Stage all files:
git add .
  1. Make your first commit:
git commit -m "Initial commit"

Step 8: Push to GitHub

  1. Push your code to GitHub:
git push -u origin master

Or if you’re on the main branch:

git push -u origin main

Step 9: Verify in VSCode

  1. In VSCode, you can now use the Source Control panel (Ctrl+Shift+G) to manage your Git repository
  2. Your repository should now be visible on GitHub

Next Steps

  • Add more code to your project
  • Create additional branches for features
  • Set up GitHub Actions for CI/CD
  • Consider adding a README.md file with project documentation

This guide was created on March 11, 2025