Setting Up Your First GitHub Repository: A Step-by-Step Guide
-
Ahmed Muhi
- 14 Apr, 2024

Introduction
Hey there, Everyone! đ Iâm excited to continue our software development journey together. Last time, we learned the fundamentals of Git in Part 1 - how to track changes, create commits, and manage our code locally. Today, weâre going to build on that knowledge by exploring GitHub.
Youâve already learned how to use Git on your computer. Now, letâs see how GitHub helps us share our code with other developers and collaborate on projects together. GitHub takes the Git concepts youâve learned and adds powerful online features that make team collaboration much easier.
In this guide, weâll cover:
- What GitHub is and why developers use it
- How to create your GitHub account
- Setting up your first GitHub repository
- Connecting your local Git repository to GitHub
- Using VS Code to work with GitHub
- Creating and managing pull requests
Donât worry if some of these terms sound unfamiliar - weâll explore each one step by step. By the end of this guide, youâll be able to:
- Store your code online securely
- Share your projects with other developers
- Collaborate on code with team members
- Review and discuss code changes effectively
Remember those Git repositories we created in the last article? Today youâll learn how to put them online where you can access them from anywhere and work with other developers.
Letâs get started with setting up your GitHub account!
Creating a GitHub Account
Now that we understand what GitHub is, letâs create your account! If you already have one, feel free to skip to the next section. For everyone else, Iâll walk you through the process step by step.
First, head over to GitHubâs website. Youâll see a signup form where GitHub asks for some basic information to get you started.
Hereâs what youâll need to provide:
- Your email address - this is where GitHub will send your verification link
- A strong password to keep your account secure
- A username that will identify you on GitHub - choose something professional since other developers will see this
The signup screen makes this process straightforward, showing you exactly what information is required with clear labels and helpful hints.
Youâll also see an option for email preferences - GitHub asks if youâd like to receive occasional product updates and announcements. This is entirely up to you!
Once youâve filled in your details, click the âContinueâ button to move forward with the signup process.
Quick Tip: Choose a username youâll be happy with long-term - this will be part of your GitHub profile URL and how other developers find you!
After clicking continue, GitHub will send a verification code to your email. This helps ensure your email address is valid and secure. Check your inbox, grab that code, and enter it when prompted.
Congratulations! đ Youâve taken your first step into GitHub. In the next section, weâll create your first repository and start putting your Git knowledge to work!
Setting Up a GitHub Repository
Now that youâve got your GitHub account ready, letâs create your first repository! You might be wondering, âWhat exactly is a repository?â Think of it as your projectâs home on GitHub - this is where all your code will live and where the magic of collaboration happens.
Let me walk you through creating your first repository step by step. Donât worry if some steps seem unfamiliar - weâll explore each one together!
Step 1: Navigate to Your GitHub Dashboard
First, letâs find where to create your repository. Once youâre logged into GitHub, look for your profile picture in the top right corner. Click on it and select Your repositories from the dropdown menu.
Step 2: Create a New Repository
Youâll see a green New button on your repositories page. This is where weâll start! Click on it to begin creating your new repository.
Step 3: Fill in Repository Details
This is where weâll set up the basic information for your repository. Youâll see a form with several options - let me explain each one so you can make the right choices for your project:
- Repository Name: Letâs name it
my-first-project
. Choose a name thatâs clear and descriptive - you can always change it later! - Description (optional): This helps others understand what your project is about. While itâs optional, I recommend adding a short description.
- Public or Private: Hereâs an important choice!
- Public means anyone can see your code (great for open source projects or learning)
- Private means only you and people you invite can see it (perfect for personal projects)
- Initialize with a README: Since weâll be connecting this to our local repository, leave this box unchecked for now.
Hereâs what your form should look like:
Once everything looks good, click that Create repository button at the bottom of the page. Exciting, right?
Step 4: Connect Your Local Repository to GitHub
Now comes the cool part - connecting your local repository to GitHub! This is where weâll bridge the gap between your computer and GitHub.
-
First, youâll need the repository URL. Look for and click the copy button next to the URL on your new repository page:
-
Open your terminal or command prompt and navigate to your project:
cd path/to/your/my-first-project
-
Now, letâs connect your local repository to GitHub:
git remote add origin https://github.com/your-username/my-first-project.git
This command tells Git âHey, I want to connect this local repository to my GitHub repository!â
-
Letâs make sure it worked:
git remote -v
You should see something like this:
origin https://github.com/ahmedmuhi/my-first-project.git (fetch) origin https://github.com/ahmedmuhi/my-first-project.git (push)
This output tells us weâre successfully connected to GitHub. Great job! đ
Step 5: Push Your Code to GitHub
Now that weâre connected to GitHub, itâs time for the exciting part - getting your code online! Letâs push your local code to GitHub:
-
Hereâs the command to push your code:
git push -u origin main
Let me explain whatâs happening here: weâre pushing your code to GitHub, and that
-u
flag is pretty clever - it helps Git remember this connection. After this, you can simply usegit push
orgit pull
without typing out all the extra details. Neat, right? -
Once thatâs done, head back to your repository on GitHub and refresh the page. You should see all your files right there on GitHub - how cool is that?
Step 6: Making Changes and Keeping GitHub Updated
Now comes the fun part - letâs make some changes and see how easy it is to keep your GitHub repository up to date!
-
First, letâs create a new file in your project:
cd your-repo-name echo "Some new content" >> newfile.txt
-
Letâs check what Git thinks about our new file:
git status
-
Time to stage our new file:
git add newfile.txt
-
Commit your changes with a clear message:
git commit -m "Add newfile.txt with initial content"
-
And finally, push it to GitHub:
git push
Notice something? We didnât need to type
origin main
this time - thatâs our-u
flag from earlier doing its job!
Congratulations! đ Youâve just:
- Created your first GitHub repository
- Connected it to your local project
- Pushed your code to GitHub
- Made changes and updated your repository
Youâre now officially using GitHub! In our next section, weâll explore how to work with branches - this is where GitHubâs collaboration features really start to shine!
Using VS Code for GitHub
Hey, remember all those commands we just learned? While theyâre great to know, thereâs an easier way to work with GitHub - using Visual Studio Code (VS Code)! VS Code is an amazing code editor that makes working with GitHub feel like a breeze. Let me show you how to set it up! đ§âđ»
Step 1: Install VS Code
First things first - if you havenât already, letâs get VS Code installed on your computer. Head over to Visual Studio Code and download it. Donât worry, itâs free!
Step 2: Get the GitHub Extension
Now hereâs where it gets interesting - VS Code has a fantastic GitHub extension that makes everything easier:
- Look for the Extensions icon in the sidebar (it looks like four squares) or just press
Ctrl+Shift+X
- Type âGitHubâ in the search bar
- Find and install the GitHub Pull Requests and Issues extension
- VS Code might ask you to restart - go ahead and do that if it does
Step 3: Open Your Project in VS Code
Letâs get your repository opened in VS Code:
- Go to File > Open Folder
- Find your
my-first-project
directory and open it
Step 4: Managing Your Repository the Visual Way
This is where VS Code really shines! Let me show you how much easier everything becomes:
-
Making Changes: Open your README.md file and make some changes. Itâs just like using any text editor!
-
Seeing Your Changes: Click the Source Control icon in the sidebar (looks like a branch). VS Code shows you exactly what changed!
-
Staging Files: See those
+
icons next to your files? One click and theyâre staged - no commands needed! -
Committing: Type your commit message in the box and click the checkmark. Simple as that!
-
Pushing to GitHub: Ready to share your changes? Click the arrow next to Commit and choose âCommit & Pushâ. Done!
And just like that, youâve mastered using VS Code with GitHub! đ Notice how everything we did with commands before is now just a few clicks away? Pretty cool, right?
In our next section, weâll look at something really exciting - creating branches and pull requests. VS Code makes this super easy too!
Creating and Managing Pull Requests with VS Code
Letâs explore one of the most powerful features of GitHub - pull requests! If youâre wondering what pull requests are, theyâre how developers propose changes and collaborate on code. VS Code makes this process straightforward, so let me show you how it works.
Step 1: Create a New Branch
Before we make any changes, we need to create a new branch. This lets us work on our changes without affecting the main code:
- Open VS Code and go to your repository
- Press
Ctrl+Shift+P
to open the Command Palette - Type
Git: Create Branch
and select it
Now give your branch a name - letâs call it my-new-feature
Step 2: Make Your Changes
Now that we have our new branch, letâs make some changes:
- First, modify any files you want to change
- When youâre ready, click the Source Control icon in the sidebar
- See those files with changes? Click the
+
icon next to each one to stage them
Add a clear commit message explaining what you changed, then click the checkmark to commit:
Step 3: Push the Branch to GitHub
Now that weâve made and committed our changes, letâs share them on GitHub:
Look at your VS Code - notice that the Commit button has changed to say âPublish Branchâ? Thatâs VS Code telling us this branch only exists on your computer right now.
Click that âPublish Branchâ button to send your changes to GitHub. Simple as that!
Step 4: Create a Pull Request
Hereâs where it gets interesting - letâs create a pull request to propose merging your changes:
- Press
Ctrl+Shift+P
again to open the Command Palette - Type
GitHub Pull Requests: Create Pull Request
and select it
VS Code will show you a form where you can set up your pull request:
- Set the base branch to
main
(this is where your changes will go) - Your
my-new-feature
branch is already selected (this is where your changes are coming from) - Add a title and description that clearly explain your changes
Step 5: Reviewing Pull Requests
Letâs look at how to review the changes youâve proposed:
- After creating your pull request, youâll see a notification at the bottom of VS Code
- A new pull request icon will appear in your sidebar - click it to see your changes
VS Code makes it easy to see exactly what youâre proposing to change. You can view all modified files and see whatâs been added or removed.
Step 6: Understanding the Review Process
Let me show you how to review your changes before merging them:
When you open your pull request in VS Code, youâll see several important pieces of information:
- The pull request details will say something like âAhmed wants to merge changes into
main
frommy-new-feature
â - You can see all the files that were changed
- Each change is highlighted - additions in green, deletions in red
You can also view your pull request on GitHubâs website - sometimes itâs nice to see everything in your browser:
Step 7: Merging Your Changes
Once youâre happy with your changes, itâs time to merge them into your main code:
- If everything looks good and there are no conflicts, look for the âMerge Pull Requestâ button
- You can add a final merge message if you want to
- Click âCreate Merge Commitâ to combine your changes with the main code
After merging, youâll see a confirmation that everything worked:
- The status changes to âMergedâ (with a nice purple color)
- VS Code asks if you want to delete your branch - itâs usually safe to do this since your changes are now in the main code
And thatâs it! Youâve successfully:
- Created a branch for your changes
- Made and committed those changes
- Created a pull request
- Reviewed the changes
- Merged them into your main code
In future articles, weâll explore more advanced features like reviewing other peopleâs pull requests and handling merge conflicts. But for now, you have all the tools you need to start collaborating on GitHub projects!
Conclusion
Well done! Youâve accomplished quite a bit in this article. Letâs quickly review what youâve learned:
You started by setting up your GitHub account and creating your first repository. Then you saw how VS Code makes working with GitHub straightforward and visual. Finally, you learned how to create and manage pull requests - a key skill for collaborating with other developers.
Hereâs what you can now do:
- Create and manage GitHub repositories
- Connect your local code to GitHub
- Use VS Code for your GitHub workflows
- Create branches for new features
- Make pull requests to propose changes
Remember, what weâve covered today is just the beginning. In our next article, weâll explore more advanced GitHub features and dive deeper into collaboration techniques.
Thank you for learning with me today. See you in the next article đđ