How to Use Git and GitHub: A Beginner’s Tutorial

Git is a version control system that records every change you make to your code. GitHub is a cloud platform that hosts Git repositories, so your work is backed up and easy to share. Together they’re the standard workflow for developers everywhere.

Getting started takes only three things: Git installed on your machine, a free GitHub account, and a terminal window.

Article illustration

1. Install and Configure Git

Download Git from git-scm.com, then tell it who you are so your commits are labeled correctly:

  • git config --global user.name "Your Name"
  • git config --global user.email "you@example.com"

2. Create a Repository and Commit

Inside your project folder, run git init to start tracking files. Then save a snapshot:

  • git add . — stage all your changes
  • git commit -m "First commit" — record the snapshot

3. Push Your Code to GitHub

Create an empty repository on GitHub, then connect your local folder to it:

  • git remote add origin https://github.com/user/repo.git
  • git push -u origin main

4. Work with Branches and Pull Requests

Never code directly on main for team projects. Create a branch with git checkout -b feature, push it, then open a Pull Request on GitHub so others can review your work before it merges.

Conclusion

Master four commands first — add, commit, push, and pull. Everything else in Git becomes much easier once those feel natural.

sarah antaboga
Author: sarah antaboga

Leave a Reply

Your email address will not be published. Required fields are marked *