How to Use GitHub Copilot to Write Your First Code in 2 Hours
How to Use GitHub Copilot to Write Your First Code in 2 Hours
If you're a beginner looking to dip your toes into coding, you might feel overwhelmed by the sheer volume of resources and tools available. The good news is that GitHub Copilot can make the process a lot easier and faster. In just two hours, you can harness the power of AI to start writing your first lines of code. In this guide, I'll walk you through how to get set up and actually write something useful, all while being straightforward about the limitations and trade-offs.
Prerequisites: What You Need Before Getting Started
Before jumping into GitHub Copilot, make sure you have the following:
- GitHub Account: You’ll need an account to access Copilot.
- Visual Studio Code (VS Code): This is the IDE where you'll use Copilot. Download it here.
- GitHub Copilot Subscription: As of August 2026, Copilot costs $10/month after a free trial.
- Basic Understanding of Coding Concepts: Familiarity with variables, functions, and control flow will help, but you don't need to be an expert.
Step 1: Setting Up GitHub Copilot
- Install Visual Studio Code: Download and install VS Code if you haven't already.
- Install the GitHub Copilot Extension: Open VS Code, go to the Extensions view (Ctrl + Shift + X), and search for "GitHub Copilot". Click "Install."
- Sign In to GitHub: After installation, you’ll be prompted to sign in to your GitHub account. Follow the prompts to authorize the extension.
Expected Output: You should see a Copilot icon in your VS Code sidebar once it's installed.
Step 2: Writing Your First Code
Let’s write a simple "Hello, World!" program in Python.
- Open a New File: Create a new file and save it as
hello.py. - Start Typing: Type
print("Hello,and wait for Copilot to suggest the rest. - Accept the Suggestion: If Copilot suggests
World!"), pressTabto accept.
Expected Output: When you run the code using python hello.py, you should see Hello, World! printed in your terminal.
Step 3: Experimenting with More Complex Code
Now that you’ve written your first line of code, let’s try something slightly more complex—a function that adds two numbers.
- Define a Function: Start typing
def add_numbers(a, b):and wait for Copilot’s suggestion. - Accept the Suggestion: If it proposes a body for the function, press
Tab. - Call Your Function: Below the function definition, type
print(add_numbers(3, 5))and run your code.
Expected Output: You should see 8 printed in your terminal.
Troubleshooting: What Could Go Wrong
- Copilot Doesn’t Suggest Code: If Copilot isn’t providing suggestions, check if you’re connected to the internet and logged into GitHub.
- Errors in Code: If your code throws an error, double-check the syntax. Copilot can make mistakes, especially with complex logic.
What’s Next? Building on Your Knowledge
Once you've mastered the basics with GitHub Copilot, consider:
- Building a Simple Project: Try creating a basic calculator or a to-do list app.
- Learning Further: Explore more complex programming concepts such as classes and APIs.
- Join Communities: Engage with other learners on platforms like GitHub Discussions or Reddit to share your projects and get feedback.
Conclusion: Start Here
GitHub Copilot can significantly reduce the learning curve for coding, allowing you to write your first code in under two hours. It’s not a magic solution; you'll still need to learn and understand the fundamentals. However, it can be a powerful ally in your coding journey.
If you're serious about getting started with coding, I recommend diving into GitHub Copilot right away. The combination of AI assistance and hands-on practice can set you on the path to becoming a competent developer.
Follow Our Building Journey
Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.