Git and GitHub

Everything you need to work with Git and GitHub, organized by task: setting up, committing, branching, merging, syncing with a remote and undoing mistakes, then the GitHub features built on top. The workflow below shows the core commands in the order you’ll use them.

Showing all 106 guides

The Git workflow in eight steps

Each step shows the commands you’ll run and links to the guides that explain them in detail.

  1. Set up Git

    Install Git, tell it who you are, and connect it to GitHub.

    git --version
    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
  2. Start a repository

    Create a new repository or copy an existing one.

    git init
    git clone https://github.com/user/repo.git
  3. Record changes

    Check what changed, stage it and commit it.

    git status
    git add file.txt
    git commit -m "Describe the change"
  4. Work on a branch

    Keep new work separate until it is ready.

    git switch -c feature-x
    git switch main
    git branch -d feature-x
  5. Sync with the remote

    Send your commits and bring in other people’s.

    git push -u origin feature-x
    git fetch
    git pull
  6. Combine work

    Bring a branch back in and settle any conflicts.

    git merge feature-x
    git rebase main
  7. Undo a mistake

    Pick the command by what you need to undo and whether it has been pushed.

    git restore --staged file.txt
    git revert <commit>
    git reset --soft HEAD~1
    git stash
  8. Investigate history

    Find out what changed, when, and who changed it.

    git log --oneline
    git blame file.txt
    git bisect start

Commands use current Git syntax. git switch and git restore arrived in Git 2.23; on older versions, use git checkout. The Git cheat sheet has every command on one page.

Git basics

10

What version control is, how Git differs from GitHub, and how to install and configure Git.

What Is Version Control? Explained with ExamplesMost people meet version control the hard way, usually through a folder full of files named final\_v2 and final\_v2\_REAL, with no clear…16 min read Updated What Is Git? A Beginner’s Guide to Version ControlEvery clone of a Git repository carries the complete history of the project. That works because Git records each commit as a…17 min read Updated What Does Git Mean? Understanding Version ControlGit is a distributed version control system. Every clone carries the full project history, so commits and history lookups run without a…15 min read Updated What Is the Difference Between Git and GitHub?GitHub can’t run without Git. Git has no such need for GitHub, and works with no account and no network connection at…13 min read Updated How to Install Git on Windows, Mac, and LinuxInstalling Git comes down to one installer or one command, depending on what you run. Windows has the Git for Windows installer…14 min read Updated What Is Git Bash? A Beginner’s Guide to Using ItInstall Git on Windows and a terminal you never asked for shows up in the Start menu. That’s Git Bash, a Bash…16 min read Updated What Is Git Config? Set Up Git Like a ProThe first thing most people do after installing Git is tell it their name and email. That’s a git config job, and…16 min read Updated How to Use Git: A Step-by-Step Guide for BeginnersMost of Git is a single loop. You change files in the working directory, run git add to stage them, then run…20 min read Updated Git Commands You Should Know as a Beginner DeveloperEver stared at your terminal wondering which git command to use next? You’re not alone. Git commands form the backbone of modern…14 min read Updated What Is a Git Workflow? A Simple Guide for BeginnersGit will let a team do almost anything with its branches. It has no opinion on who merges, when, or after whose…17 min read Updated

Repositories and remotes

11

Create and clone repositories, and understand remotes, origin and upstream.

What Is a Git Repository? Everything You Should KnowGit keeps a project’s full change history as commits in a content-addressed object database, and that database is what people call a…16 min read Updated What Does Git Init Do? Learn MoreRun git init in a folder and a hidden .git directory appears inside it. Objects, refs/heads, refs/tags and the template files all…13 min read Updated What Is Git Clone? How to Copy a Git RepositoryMost developers run git clone on their first day with a project and then barely think about it again. The command copies…15 min read Updated How to Clone a Git Repository in Simple StepsOpen a terminal and run git clone with the repository URL after it. Git makes a new local folder, copies the project…15 min read Updated How to Clone a GitHub RepositoryCloning a GitHub repository comes down to git clone and the HTTPS or SSH URL from the repository’s Code button. Git makes…16 min read Updated What Is a Remote Repository? Explained SimplyGit keeps the full history on every machine, which works fine until a second person joins the project. Then somebody has to…16 min read Updated What Is Origin in Git? Everything You Should KnowMost people meet the word origin by pasting a command from a README, and they never stop to ask where it came…14 min read Updated What Is Git Remote? Manage Connections EasilyGit has no memory for server addresses. Every fetch, pull and push needs one, and git remote is the command that attaches…14 min read Updated What Is Upstream in Git? Explained with ExamplesRun git pull in a fresh clone and it just works, because Git already linked the default branch to its remote counterpart.…14 min read Updated What Is a Bare Repository? When and Why to Use OneOpen a bare repository in a file browser and you won’t find a single project file. No index.html, no src folder, nothing…14 min read Updated What Is Gitignore? Understand It in 5 MinutesEvery project folder collects files Git has no business storing. Compiled output, a node\_modules folder with thousands of entries, last Tuesday’s log…14 min read Updated

Staging, committing and history

13

Track changes from the working directory to a commit, and read the history afterwards.

What Is Git Status? How to Track File ChangesRun git status and Git compares the HEAD commit, the index, and the working tree against each other. You get back a…17 min read Updated What Is Staging in Git? A Beginner-Friendly IntroA plain git commit records the contents of the index and nothing else. The index is also called the staging area, and…12 min read Updated What Is Git Add? Learn How to Stage Changes FastA commit run with no extra arguments records what the index holds and nothing else. git add is the command that puts…12 min read Updated What Does Git Commit Do? Understand Its RoleMost of the confusion around git commit comes from assuming it saves your files. It saves the staging area, which is a…15 min read Updated What Is a Commit Hash? Why It Matters in GitEvery commit in Git gets a name you never picked. It shows up in the terminal right after you commit, a short…14 min read Updated How to Unstage a File in Git in Simple StepsMost of the time, unstaging a file in Git is one command: git restore –staged <file>. It pulls the file out of…12 min read Updated What Is Git RM? How to Safely Remove FilesDeleting a tracked file by hand takes two steps. You remove it from disk, then you tell Git about it. git rm…13 min read Updated What Is Git Clean? Remove Untracked Files FastMost untracked files in a project are junk. Build output, a scratch file called test2.txt that nobody remembers creating. git clean removes…13 min read Updated What Is Git Diff? How to Compare File ChangesReviewing edits before a commit and comparing branches before a merge are what git diff gets used for most. It prints line-level…15 min read Updated What Is Git Log? A Quick Look at Git HistorySomebody changed that config file last month and nobody remembers who. Or a bug showed up in the latest release and you…14 min read Updated What Is Git Blame? Uncover Code ChangesRun git blame on a file and every line comes back with the commit, author and date of its last change printed…15 min read Updated What Is Git Tag? Marking Versions Made EasyCommit hashes work fine for Git and badly for people. A tag fixes that by putting a readable name on one commit,…14 min read Updated What Does Git Stash Do? Save and Restore ChangesSay you’re halfway through a change and someone needs you on another branch right now. git stash shelves that unfinished work on…15 min read Updated

Branches and branching strategies

9

Create, switch, rename and delete branches, and choose a strategy such as Git Flow or trunk-based development.

What Is a Git Branch? Explore Its PurposeA Git branch is a pointer to a commit, saved as a small file that holds one hash. Making one copies no…16 min read Updated How to Create a New Branch in Git the Right WayRun git switch -c feature-login and Git creates the branch and moves you onto it. For most people that’s the whole job.…12 min read Updated How to Switch Branches in Git Easilygit switch branch-name moves you to another branch. It arrived in Git 2.23, released August 16, 2019 (GitHub Blog, 2019), and older…13 min read Updated What Is Git Checkout? Switch Branches Like a ProType git checkout and Git does one of two quite different jobs, depending on what comes next. Hand it a branch or…14 min read Updated How to Rename a Branch in Git Without ErrorsRun git branch -m new-name and the local branch has a new name. The remote needs a push under the new name…12 min read Updated How to Delete a Branch in Git SafelyRun git branch -d branch-name to remove a local branch. The copy on the remote needs its own command, git push origin…13 min read Updated What Is a Detached HEAD in Git?Git lets you stand on any commit in history and keep working, which is fine until you notice HEAD has stopped following…13 min read Updated What Is Git Flow? A Beginner-Friendly GuideVincent Driessen published Git Flow in 2010, back when most teams shipped software as numbered versions. The model sorts work into five…14 min read Updated What Is Trunk Based Development? Explained SimplyMost teams land on trunk-based development after one too many merges of a branch that drifted for three weeks. Developers merge small,…15 min read Updated

Pushing, pulling and fetching

7

Keep your local repository and the remote in step.

Merging, rebasing and conflicts

7

Combine branches, clean up commits and find the change that broke something.

Undoing mistakes

5

Revert, reset or delete commits safely, depending on whether they have been pushed.

GitHub: account and repositories

15

Create and manage repositories on GitHub, and keep your account and secrets safe.

What Is GitHub? A Beginner’s OverviewGitHub is a web-based code hosting platform. It keeps Git repositories online and layers pull requests, issue tracking and workflow automation over…15 min read Updated What Is GitHub Used For? ExplainedTeams use GitHub to keep code in one place, review every change before it goes in, and ship from the same site.…15 min read Updated Is GitHub Safe? Security InsightsGitHub holds SOC 1 and SOC 2 Type 2 reports and ISO/IEC 27001:2022 certification (GitHub Docs), so the platform itself is run…18 min read Updated How to Use GitHub: Step-by-Step GuideMost people land on GitHub because someone sent them a repository link and said “clone this.” The routine from there is short.…21 min read Updated How to Create a Repository in GitHub From ScratchEvery project starts somewhere. For most developers today, it starts with a GitHub repository. GitHub hosts over 630 million repositories and 180…20 min read Updated How to Make a Repository Private in GitHubLeaving the wrong repository public can expose your source code, API keys, or proprietary logic to anyone on the internet. Knowing how…20 min read Updated How to Make a Repository Public in GitHubOne settings change turns your private project into something the entire developer community can see, clone, and build on. Knowing how to…16 min read Updated How to Rename a Repository in GitHub: Quick GuideA repository name is more than a label. It shows up in every clone URL, every webhook, every CI/CD config your team…17 min read Updated How to Delete a Repository in GitHubOpen the repository’s Settings, scroll down to the Danger Zone, and click Delete this repository. GitHub shows a couple of warnings, and…12 min read Updated How to Download from GitHub EasilyPlenty of people click Download ZIP on GitHub and never think about it again, which is fine until they need the history…14 min read Updated How to Commit to GitHub RepositoryTwo commands, git add and git commit -m, build a snapshot in the local repository. A third, git push, is what puts…15 min read Updated How to Change Your GitHub UsernameOpen Settings, go to Account, click Change username, and pick a name nobody else holds. Personal accounts can do this. Enterprise Managed…10 min read Updated How to Add SSH Key to GitHubGit can log in to GitHub with a key instead of a password or token. Generate a pair with ssh-keygen, paste the…16 min read Updated How to Get a GitHub Token: Easy StepsGit stopped accepting account passwords over HTTPS a while back, so typing yours at a prompt today just gets rejected. A personal…16 min read Updated How to Hide an API Key in GitHub RepositoriesPutting an API key in a repository takes about four seconds, and getting it back out can eat an afternoon. Keep the…16 min read Updated

GitHub: branches, forks and pull requests

10

Collaborate on GitHub with branches, forks, pull requests and project boards.

How to Create a Branch in GitHub: Step-by-StepEvery production incident you have ever seen started with someone pushing directly to main. Knowing how to create a branch in GitHub…21 min read Updated How to Rename a Branch in GitHub Without Breaking ThingsA typo in a branch name, a scope change midway through a sprint, a team-wide naming convention update – there are plenty…20 min read Updated How to Delete a Branch in GitHubDeleting a branch in GitHub takes the trash icon on the repository’s branches page or one command: git push origin --delete feature-login.…14 min read Updated How to Compare Branches in GitHub EffectivelyBranch divergence is one of the most common sources of broken merges, missed changes, and wasted review time in collaborative development. Knowing…22 min read Updated How to Merge Branches in GitHubThe green merge button doesn’t look the same on every repository. Some show one option, some show several, and a few show…16 min read Updated What Is a Fork in GitHub? Learn NowForking is how most people end up contributing to a project they don’t own. You get your own copy on GitHub, change…15 min read Updated How to Fork a Repository in GitHub and Why It MattersEvery major open source contribution starts the same way: someone forks a repository. Knowing how to fork a repository in GitHub is…19 min read Updated How to Create a Pull Request in GitHub EasilyMost developers know Git. Far fewer know how to use the pull request workflow without running into merge conflicts, wrong base branches,…21 min read Updated How to Approve a Pull Request in GitHub QuicklyMost developers know how to open a pull request. Fewer know exactly what happens during the approval step, and why getting it…21 min read Updated How to Use GitHub Projects to Manage Your WorkMost engineering teams already have their code on GitHub. Their project tracking lives somewhere else entirely. That split creates real friction. Knowing…22 min read Updated

GitHub tools and features

13

GitHub Desktop, the CLI, Codespaces, Actions, Pages, Gist and Copilot.

What Is GitHub Desktop and Why Should You Use It?Most developers know Git. Not all of them enjoy using it from a terminal. GitHub Desktop is a free, open-source GUI client…20 min read Updated How to Use GitHub Desktop: A Beginner’s WalkthroughGit is the backbone of modern software development, used by 93.87% of developers worldwide as of 2025. But the command line stops…21 min read Updated How to Install GitHub CLI on Any Operating SystemMost developers still switch between the terminal and a browser dozens of times a day. That context switching adds up. Learning how…15 min read Updated How to Use GitHub CLI to Supercharge Your WorkflowMost developers already have a terminal open. The browser tab for GitHub is the one nobody asked for. Learning how to use…23 min read Updated What Is GitHub Codespaces? A Beginner’s GuideSetting up a local development environment still eats hours that could go toward actual coding. GitHub Codespaces is a cloud-based development environment…20 min read Updated What Are GitHub Actions? A Quick GuideGitHub Actions runs automated workflows from inside a GitHub repository. Each workflow is a YAML file, and it starts when something happens…17 min read Updated What Is GitHub Pages? Host Your Site for FreeYou already have the code. You already have the repository. So why pay for hosting? GitHub Pages is a free static site…15 min read Updated How to Host a Website on GitHubTo host a site on GitHub you need a repository with an entry file such as index.html in it, plus a publishing…16 min read Updated How to Deploy to GitHub Pages in MinutesFree static site hosting, built directly into your existing workflow. That is what GitHub Pages offers, and most developers never fully use…19 min read Updated What Is GitHub Gist? Share Code Snippets InstantlyMost developers have shared code the wrong way at least once. A Slack message with broken indentation. An email thread no one…19 min read Updated What Is GitHub Copilot? Explained SimplyGitHub Copilot suggests code as you type, answers questions in a chat panel and, in its newer modes, makes multi-step changes across…20 min read Updated How to Use GitHub Copilot EffectivelyOlder Copilot tutorials have a problem. They talk about premium request limits, and those are gone. Since June 1, 2026, GitHub bills…21 min read Updated GitHub statistics that define collaborationEvery developer knows the platform, but few understand the massive scale behind it. GitHub statistics reveal a software development ecosystem that’s reshaping…7 min read Updated

Git in your editor

6

Use Git and GitHub from VS Code, PyCharm and Android Studio.

Frequently asked questions

What is the difference between Git and GitHub?

Git is the version control tool that runs on your computer and records the history of your files. GitHub is a hosting service for Git repositories that adds collaboration features such as pull requests, issues, Actions and Pages.

What is the difference between git merge and git rebase?

Merge combines two branches with a merge commit and keeps the history exactly as it happened. Rebase replays your commits on top of another branch, which gives a linear history but rewrites those commits, so avoid rebasing commits others already use.

How do I undo the last commit?

If the commit hasn’t been pushed, git reset --soft HEAD~1 removes it and keeps your changes staged. If it has been pushed, use git revert, which adds a new commit that reverses it without rewriting shared history.

What is the difference between git fetch and git pull?

git fetch downloads new commits from the remote without changing your working files. git pull runs a fetch and then merges (or rebases) those commits into your current branch.

Do I need GitHub to use Git?

No. Git works entirely on your own machine. GitHub, GitLab or Bitbucket only come in when you want a shared remote copy for backup or collaboration.

These guides are written by Bogdan Sandu and published by TMS Outsource, a custom software development company founded in 2014, with engineering offices in Belgrade and Bucharest. If you need a team to build or extend a web or mobile product, see our software development services or get in touch.