/

Developer Workflow

Mar 3, 2025

Mar 3, 2025

A beginner's guide to getting started with GitHub

New to GitHub? Learn basic concepts like repositories, branches, and pull requests to start your open-source journey.

github for beginners guide
github for beginners guide
github for beginners guide

Do you ever find yourself wondering, "What is GitHub?" or wishing you had the opportunity to learn the basics of Git? If so, you've come to the right place! I know you probably have a ton of questions, and I’m genuinely excited to help you navigate through them all.

Today, I’m going to dive into the basics of getting started with GitHub.

I’ll walk you through everything from setting up your GitHub account to understanding how to contribute using  GitHub flow, merging your first pull request, and finally discussing some tips with common pitfalls to avoid.


What is GitHub and why is it important?

Well, GitHub is a cloud-based platform where you can store, share, and work together with others to write code. Under the hood, it is powered by Git, a distributed version control system designed to track changes in our code.

Git tracks different versions of your project’s progress as you develop, while GitHub handles hosting and distribution on its servers. As a result, you can reliably access code changes from any computer with internet access.

In a traditional development environment without source control systems, collaboration can be cumbersome. 

For instance, before GitHub emerged, developers often relied on mailing lists and patch submissions. They would create patches (diff between versions) and send them via email for review.

Maintainers would then manually apply these patches to the codebase. This process mostly led to confusion at times, as tracking feedback was disjointed.

GitHub revolutionized this process by integrating community features directly into the development workflow. Issues, pull requests, discussions, and CI/CD are all part of the same platform.

➡️ This means that when a developer submits a code change proposal, their colleagues can review and make code suggestions, tag open bug issues, and run automated workflow against those changes — all in one place.

Without tools like GitHub and Git, open-source development wouldn’t be what it is today.

Speaking of open-source, some open source llms can't be missed even if you are a beginner, same goes for llm trends if you want to be a top-notch dev.


Set up your GitHub account and configure Git

To get started with GitHub, you'll need to create an account. Head over to their sign-up page and follow the prompts to create a personal account.

Next, you'll want to make sure Git is installed and configured with your GitHub info. While Git comes pre-installed on some macOS and Linux-based systems, Windows does not include Git by default, so you'll need to install it separately. 

You can easily verify if Git is installed by executing the following command in your terminal:

git version

If you see a message along the lines `command not found`, that means you don’t have it installed. No worries — you can download Git for your operating system here.

Once Git is installed, it’s time to set up your name and email in your global gitconfig.

In your terminal, run the following commands, substituting the placeholders with your own details:

git config --global user.name "First Last"
git config --global user.email "youremail@example.com"

To confirm that your Git username and email were set correctly, run these commands:

git config --global user.name
git config --global user.email

You should see the credentials you entered earlier. For example, on my computer, this is what I get:

git config --global user.name
Emmanuel Isenah
git config --global user.email
emmanuelisenah@gmail.com

Next, to push changes between your local machine and GitHub, you need to authenticate. If you're cloning a private repository, you'll also need to authenticate.

Public repositories, on the other hand, can be cloned without being authenticated.

There are two main protocols for authentication: https and ssh. While HTTPS authentication can work fine, using SSH is often the preferred secure method, especially with GitHub disabling using your account password to authenticate. 

Besides, SSH is way more convenient as it allows you to push changes without needing to enter your username and token every time.

If you must authenticate with https, you'll have to create a Personal Access Token with specific permissions.

To get started with SSH, you'll first need to generate an SSH key if you haven’t done so already. You can create one by running the following command in your terminal:

ssh-keygen -t ed25519 -b 4096 -C "youremail@example.com"

Replace "youremail@example.com" with the email associated with your GitHub account.

Once you’ve generated the key, add it to your SSH agent. Your SSH agent holds your private SSH keys in memory and provides them to SSH clients when requested:

eval "$(ssh-agent -s)"ssh-add ~/.ssh/id_ed25519

Next, you’ll need to add the SSH key to your GitHub account. You can easily do this using the GitHub CLI, or from your GitHub profile settings if you prefer a GUI. You don't have to choose, I’ll show you both methods:

If you don’t have the GitHub CLI installed yet, it’s available via Homebrew, Conda, Webi, and many other package managers for all operating systems.

Once you have the GitHub CLI installed, log in using the following command:

gh auth login  --git-protocol ssh --web

You should receive a prompt asking if you want to upload your SSH public key. You’ll also be prompted to add a title to help you identify which machine this key is for.

Select the Ed25519 key you generated and hit enter:

? Upload your SSH public key to your GitHub account[Use arrows to move, type to filter]> /home/emmanuel/.ssh/id_ed25519.pub  Skip? Title for your SSH key? [default: GitHub CLI]

After that, you'll be redirected to your browser to complete the login process:

Screenshot demonstrating the process of entering a one-time code for device activation in GitHub

After finishing that, head back to your terminal. You should see a successful login message that looks something like this:

! First copy your one-time code: 032E-714DPress Enter to open https://github.com/login/device in your browser...k✓ Authentication complete.- gh config set -h github.com git_protocol ssh✓ Configured git protocol✓ Logged in as Armadillidiid

To verify that everything was successful, you can use the command gh auth status. You should see information similar to this, with ssh as your git operations protocol.

github.com  Logged in to github.com account Armadillidiid (keyring)  - Active account: true  - Git operations protocol: ssh  - Token: gho_************************************  - Token scopes: 'gist', 'read:org', 'repo'

That's it, you've set up your local machine to interact with GitHub using SSH.

If you prefer a GUI, you can add SSH key by navigating to your profile under SSH and GPG Keys. In this page, you’ll find a button labeled "New SSH Key."

Clicking it will prompt you for the same details you entered when you used the CLI.

Additionally, just below the button, you should be able to view a list of SSH keys associated with your account, labeled with the title you assigned to it.

Screenshot of the SSH key settings section in the GitHub interface, showing options to add and manage SSH keys.


What are repositories, branches, commits, and pull requests?

  • Repository: A repository (or repo for short), is a space where project files live, allowing for version control and collaboration. You can think of it as a project folder that tracks changes, stores history, and lets multiple people work together.

  • Branch: A branch is a separate version of your code within a repository. It allows you to work on different features or bug fixes in isolation without affecting the default codebase (often referred to as main). Once you’re satisfied with the changes on a branch, you can merge them back into the main branch.

  • Commit: A commit is a snapshot of your entire repository at a specific point in time compressed into a SHA. It records changes you've made to the code in your branch, along with a message describing those changes. Each commit contributes to the project's history in the form of a linked list.

  • Pull Request: A pull request is a way to propose changes you've made on a branch to be merged back into the main branch. It allows collaborators to compare and discuss the differences introduced before the changes are integrated.


Understanding the GitHub workflow

If you've ever worked on a project with dozens of developers, you know that without a structured way to contribute changes, things become a hot mess real quick—sadly, I know this from experience.

Over the years, the combination of common Git practices with GitHub's native features has led to a widely accepted workflow coined by GitHub as "GitHub flow."

If you’re working in a team, there’s a good chance you’re already utilizing some aspect of this workflow.

Visual representation of GitHub flow, illustrating the process of branching, making changes, and merging pull request back into the main branch.


So, what is GitHub flow?

It is a branch-based workflow that involves creating a new branch for each feature or bug fix, making changes, opening a pull request for review, and merging those changes back into the main branch once approved.

In this section, I’ll walk you through the GitHub flow by creating a simple JavaScript project.

Create a repository

Log into GitHub and click the green "New" button on your profile dashboard. On the next page, enter a name for your repository, choose the owner (usually you), and select whether to make it public or private.

Upon submitting, you should have a new repository.

Create a branch

The first step in adding code to your repository is to create a new branch. Branching allows you to have different versions of your repository at the same time, which is essential for protecting your main branch.

This is because the main branch serves as the stable version of your project and is often deployed to production or distributed.

By branching off from the main branch, you gain the ability to make changes without risking the stability of the main codebase. Once your changes are finished and tested, you can confidently merge the branch back into the main branch.

To create a new branch, click the dropdown menu that says `main` to view all branches. There, you’ll find a button labeled "New branch."

Click it, enter a name for your new branch, and then click "Create new branch."

Clone repository

Cloning a repository creates a copy of your repository locally on your machine, allowing you to make changes and test them without affecting the version hosted on GitHub.

To clone your repository, navigate to your repository's main page on GitHub. Look for the green "Code" button and click on it. Copy the ssh URL displayed, then navigate to the directory on your machine where you want to store the cloned repository. Run the following command:

git clone <https://github.com/your-username/repo-name.git>

Replace <https://github.com/your-username/repo-name.git> with the actual URL you copied.

Make and commit changes

You can easily make and save changes to the files in your repository, which are referred to as commits on GitHub, just like in Git.

Before making any changes, ensure you're on the correct branch by switching to it:

git checkout branch-name

Once you’re on the right branch, using your preferred code editor, create the code you’d like to upload. Once you're satisfied with your changes, head back to your terminal.

Running git status will show you which files have been changed. 

git statusOn branch devYour branch is up to date with 'origin/my-first-branch'.Untracked files:  (use "git add <file>..." to include in what will be committed)    	package.json    	main.jsno changes added to commit (use "git add" and/or "git commit -a")

To commit them, you first need to add these files to the staging area using:

git add

This command includes all modified files. After that, commit your changes with a clear message by running:

git commit -m "My commit message"

Make sure to replace "My commit message" with a brief description of your changes.

Push changes and open a pull request

Now that your changes are committed locally, it’s time to push them to your remote repository on GitHub. Use the following command:

git push origin my-first-branch

Once the push is complete, you can create a pull request directly from the command line using the following GitHub CLI command:

gh pr create --base main --web

This initiates the review process, allowing you or your team members to check your changes and provide feedback before merging them into the `main` branch.

Merge your pull request

Once your pull request has been reviewed, it’s time to merge it into the main branch.

Simply navigate to your pull request page. You’ll see a big green button labeled “Merge pull request.”

Click it, and GitHub will prompt you to confirm the merge.

After confirming, your changes will be integrated into the main branch.


Conclusion

I want to applaud you for making it this far. 

You’ve successfully learned the essentials of GitHub, from creating a repository all the way to merging your first pull request using the GitHub flow.

These foundational skills open up endless opportunities for collaboration, especially in the realm of open source.

As you continue your journey with GitHub, keep in mind that tools like Pieces can be your trusted ally.

Many beginners and students have found Pieces to be an essential companion in their learning process. 

Also, myself including, found 2-day GitHub Bootcamp in a Box quite useful. 

Written by

Written by

SHARE

A beginner's guide to getting started with GitHub

Title

Title

our newsletter

Sign up for The Pieces Post

Check out our monthly newsletter for curated tips & tricks, product updates, industry insights and more.

our newsletter

Sign up for The Pieces Post

Check out our monthly newsletter for curated tips & tricks, product updates, industry insights and more.

our newsletter

Sign up for The Pieces Post

Check out our monthly newsletter for curated tips & tricks, product updates, industry insights and more.