Start here




The Git workflow in eight steps
Each step shows the commands you’ll run and links to the guides that explain them in detail.
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"Start a repository
Create a new repository or copy an existing one.
git init git clone https://github.com/user/repo.gitRecord changes
Check what changed, stage it and commit it.
git status git add file.txt git commit -m "Describe the change"Work on a branch
Keep new work separate until it is ready.
git switch -c feature-x git switch main git branch -d feature-xSync with the remote
Send your commits and bring in other people’s.
git push -u origin feature-x git fetch git pullCombine work
Bring a branch back in and settle any conflicts.
git merge feature-x git rebase mainUndo 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 stashInvestigate 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
10What version control is, how Git differs from GitHub, and how to install and configure Git.
Repositories and remotes
11Create and clone repositories, and understand remotes, origin and upstream.
Staging, committing and history
13Track changes from the working directory to a commit, and read the history afterwards.
Branches and branching strategies
9Create, switch, rename and delete branches, and choose a strategy such as Git Flow or trunk-based development.
Pushing, pulling and fetching
7Keep your local repository and the remote in step.
Merging, rebasing and conflicts
7Combine branches, clean up commits and find the change that broke something.
Undoing mistakes
5Revert, reset or delete commits safely, depending on whether they have been pushed.
GitHub: account and repositories
15Create and manage repositories on GitHub, and keep your account and secrets safe.
GitHub: branches, forks and pull requests
10Collaborate on GitHub with branches, forks, pull requests and project boards.
GitHub tools and features
13GitHub Desktop, the CLI, Codespaces, Actions, Pages, Gist and Copilot.
Git in your editor
6Use Git and GitHub from VS Code, PyCharm and Android Studio.
No guide matches .
Try a shorter search, or .
Related resources
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.