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
- Open your terminal in VSCode (Terminal > New Terminal)
- Navigate to where you want to create your project
- 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
- Navigate into the project directory:
cd Colors
- Examine the created files (typically a pyproject.toml, src directory, etc.)
Step 4: Initialize Git Repository
- Initialize a Git repository:
git init
- 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
- Open a web browser and go to GitHub
- Log in to your GitHub account
- Click the “+” button in the top-right corner and select “New repository”
- Name your repository “Colors”
- Add a description (optional)
- Choose whether to make it public or private
- Don’t initialize with a README, .gitignore, or license since we’re importing an existing repository
- Click “Create repository”
Step 6: Link Your Local Repository to GitHub
- 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
- Stage all files:
git add .
- Make your first commit:
git commit -m "Initial commit"
Step 8: Push to GitHub
- 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
- In VSCode, you can now use the Source Control panel (Ctrl+Shift+G) to manage your Git repository
- 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