How to Write Your First Lines of Code Using GitHub Copilot in 2 Hours
How to Write Your First Lines of Code Using GitHub Copilot in 2026
As someone who has navigated the often confusing waters of coding, I know how daunting it can be to write your first lines of code. You might feel overwhelmed by the syntax, the tools, and the sheer amount of information out there. But what if I told you that you could harness the power of AI to help you get started? Enter GitHub Copilot, a tool that can assist you in writing code, making the learning curve a bit less steep. In this guide, I’ll walk you through how to write your first lines of code using GitHub Copilot in just 2 hours.
Prerequisites: What You Need Before Starting
Before diving in, here are a few things you’ll need:
- GitHub Account: Sign up for free at GitHub.
- Visual Studio Code (VS Code): Download and install it from Visual Studio Code.
- GitHub Copilot Subscription: As of May 2026, Copilot is priced at $10/month after a 60-day free trial.
- Basic Understanding of Programming Concepts: Familiarity with coding concepts like variables and functions will help, but it’s not mandatory.
Step 1: Setting Up Your Environment (30 minutes)
- Install Visual Studio Code: Once installed, open it and go to Extensions (or press
Ctrl + Shift + X). - Search for GitHub Copilot: Install the GitHub Copilot extension.
- Sign in to GitHub: Follow the prompts to authenticate your GitHub account with VS Code.
- Create a New File: Start a new file and save it with a
.jsextension if you want to code in JavaScript.
Expected Output: You should see the GitHub Copilot icon in your VS Code sidebar.
Step 2: Writing Your First Lines of Code (30 minutes)
- Start Simple: Type a comment like
// Function to add two numbersand hit enter. - Let Copilot Suggest Code: Copilot will suggest a function based on your comment. Accept the suggestion by pressing
Tab. - Test Your Code: Type
add(2, 3);and run the code in the integrated terminal.
Expected Output: You should see 5 printed in the terminal.
Step 3: Experiment with Different Functions (30 minutes)
- Change the Functionality: Modify your comment to
// Function to multiply two numbers. - Accept the New Suggestion: Again, let Copilot do the heavy lifting and accept the suggested code.
- Run Your New Function: Test it out just like you did before.
Expected Output: You should see the product of the numbers you input.
Troubleshooting: What Could Go Wrong
- No Suggestions from Copilot: Make sure you are signed in to your GitHub account and that the extension is enabled.
- Errors in Code: If Copilot suggests code that doesn’t work, don’t hesitate to modify it or write your own. It’s part of the learning process.
What’s Next: Leveling Up Your Skills
After you’ve written your first lines of code, consider the following steps:
- Explore More Complex Functions: Try implementing loops, conditionals, or even object-oriented programming.
- Join Coding Communities: Platforms like Stack Overflow or Dev.to can provide invaluable support.
- Build a Small Project: Start a simple project like a to-do list app to solidify your skills.
Conclusion: Start Here
If you're looking to write your first lines of code, GitHub Copilot is a solid choice to help you along the way. It reduces the intimidation factor of coding and allows you to focus on learning the concepts. In just 2 hours, you can get comfortable enough to start experimenting with your own code.
Remember, coding is a journey, and every line you write takes you one step closer to being proficient.
Follow Our Building Journey
Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.