Coding

How to Use GitHub: A Beginner's Guide to Your First Repo

To use GitHub, create a free account, make a repository with the New repository button, then change files on a branch, commit the change and merge it with a pull request. You can do all of that in the browser, and the same workflow works from the command line with Git once you are ready to work on your own computer.

The steps below follow GitHub's own "Hello World" tutorial, then add the command-line version. The button names are the ones GitHub's documentation uses as of November 2026. GitHub changes its interface from time to time, so a label may look slightly different on your screen.

What GitHub is, and how it differs from Git

Git is a version control tool. It tracks changes to files, lets people work on their own copies of a project and merges the changes safely. GitHub is a cloud platform that hosts Git projects and adds planning and collaboration features on top. GitHub calls those hosted projects repositories.

A few terms you will meet straight away:

  • Repository (repo): a project folder with its full change history.
  • Commit: a saved snapshot of your changes, with a message describing them.
  • Branch: a separate line of work, so you can try changes without touching the main version. The default branch in a new repository is main.
  • Pull request: a proposal to merge one branch into another, where the changes can be reviewed first.

Step 1: Create a repository

  1. Sign in to GitHub. In the upper-right corner, click the + icon, then New repository.
  2. In the Repository name box, type hello-world.
  3. Optionally add a short description.
  4. Choose Public or Private.
  5. Select Add a README file.
  6. Click Create repository.

The README is a file called README.md that describes the project. GitHub shows it on the repository's front page. Ticking the box means the repository starts with one file in it, which gives you something to edit in the next steps.

Step 2: Create a branch

  1. Open the Code tab of your repository.
  2. Above the file list, click the dropdown labeled main.
  3. Type readme-edits in the text box.
  4. Click Create branch: readme-edits from main.

You are now looking at the readme-edits branch. It starts as an exact copy of main. Anything you change here stays off main until you merge it.

Step 3: Edit a file and commit the change

  1. Click README.md in the file list.
  2. Click the pencil icon (Edit file).
  3. Write a few lines about yourself or the project.
  4. Click Commit changes.
  5. Write a commit message in the box. Say what changed, for example "Add a short intro".
  6. Click Commit changes again to save the commit to readme-edits.

When you edit in the browser, the editor also has a Preview tab, and you can turn on Show diff to see exactly which lines you changed before you commit.

Step 4: Open a pull request

  1. Click the Pull requests tab, then New pull request.
  2. Choose readme-edits to compare with main.
  3. Review the diff, then click Create pull request.
  4. Enter a title and a description, then click Create pull request a second time.

On a team project, this is where teammates read your change and comment on it. On a solo practice repository you can review it yourself and move straight on.

Step 5: Merge the pull request

  1. At the bottom of the pull request, click Merge pull request.
  2. Click Confirm merge.
  3. Optionally click Delete branch to remove readme-edits, since its changes are now in main.
  4. Open the Code tab to see your edit on main.

That is the whole core loop: branch, commit, pull request, merge. Everything else on GitHub is built around it.

How to use GitHub from your computer

To work on files locally you need Git installed, plus a way to sign in to GitHub from it. First tell Git who you are, because every commit records an email address:

git config --global user.email "YOUR_EMAIL"
git config --global user.email

The second command prints the address you just set. You can use your GitHub-provided noreply address or any other address. If you want your commits to show in your GitHub contributions graph, add that address to your GitHub account. To use a different address in one repository only, run git config user.email "YOUR_EMAIL" from inside it.

Sign in over HTTPS

GitHub's documentation recommends that HTTPS users use GitHub CLI or Git Credential Manager (GCM) so Git remembers their credentials. With GitHub CLI, run gh auth login, choose HTTPS as the Git protocol, and answer yes when asked whether to authenticate Git with your GitHub credentials. With GCM, the first HTTPS clone that needs authentication opens a browser window to sign in, and GCM handles two-factor authentication for you. If you prefer SSH, you must generate an SSH key on each computer you push from.

Clone your repository

On the repository's main page, click Code above the file list, and under HTTPS click the copy icon. Then open Terminal on macOS or Linux, or Git Bash on Windows, move to the folder where you want the copy, and run:

git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY

This creates a folder with the repository's files inside it, linked to the copy on GitHub.

Commit and push a change

This sequence is taken from GitHub's repository quickstart. It creates a README, checks the state of the folder, commits it and pushes it:

echo "info about this project" >> README.md
git status
git add README.md && git commit -m "Add README"
git push --set-upstream origin HEAD

git status should list README.md as an untracked file before you stage it with git add. git commit -m records the snapshot with your message, and git push sends it to GitHub. After the push, refresh the repository page and the new commit appears there.

Create a repository from the command line

If you have GitHub CLI installed, you can skip the website for this step too:

gh repo create project-name --public

Use --private or --internal instead of --public to change the visibility, and add --clone to get a local copy at the same time. Running gh repo create with no flags starts interactive prompts, where you choose Create a new repository on GitHub from scratch.

Mistakes beginners make

  • Committing secrets. Anything you push to a public repository is visible to everyone. Keep passwords and API keys out of your files.
  • Committing straight to main. It works, but GitHub's own quickstart recommends a new branch when you are on the default branch, so the main version stays clean until you merge.
  • Vague commit messages. A message like "stuff" tells nobody what changed. One short sentence about the change is enough.
  • Mixing up the commands. git commit saves a snapshot only on your computer. Nothing reaches GitHub until you run git push.

Frequently asked questions

What is the difference between Git and GitHub?
Git is a version control tool that tracks changes to files on your computer. GitHub is a cloud platform that hosts Git projects, called repositories, and adds collaboration features such as pull requests. You can use Git without GitHub, but GitHub is built around Git.
Do I need the command line to use GitHub?
No. You can create a repository, create a branch, edit files, commit, open a pull request and merge it entirely in the GitHub website. The command line becomes useful when you want to work on files on your own computer and push them to GitHub.
Should my first repository be public or private?
Either works for learning. When you create a repository you choose Public or Private. Public repositories are visible to everyone, so do not put passwords, API keys or personal data in one. Private is the safer choice for practice projects.
What is a pull request?
A pull request is a proposal to merge the changes from one branch into another, usually into main. It shows the difference between the two branches so others can review it before you merge it.
How do I get a repository onto my computer?
Use git clone with the repository's HTTPS URL, which you can copy from the green Code button on the repository page. For example: git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY. This creates a local copy that is linked to the one on GitHub.

Sources