Git is a free, open-source distributed version control system created by Linus Torvalds.
It helps developers:
Learn how to write computer programs
With Git, every developer has a full copy of the repository on their machine, making it fast, reliable, and able to work offline.
Learn how to use Git version control
Git is commonly used to:
Every commit records a snapshot of your project.
Develop features independently and merge them later.
Multiple developers can work simultaneously without collisions.
Platforms like GitHub, GitLab, Bitbucket store your code online.
Git logs, diffs, and blame help you track who changed what — and why.
| Command | Usage |
|---|---|
git config --global user.name "Name" | Set your Git username |
git config --global user.email "email@example.com" | Set your Git email |
git config --list | Display all Git configurations |
git config --global core.editor "editor" | Set default text editor |
git config --global color.ui auto | Enable colored output |
| Command | Usage |
|---|---|
git help <command> | Help for a command |
git <command> --help | Detailed manual |
git help -a | List all Git commands |
| Command | Usage |
|---|---|
git init | Initialize a new local repository |
git clone <url> | Clone an existing repository |
| Command | Usage |
|---|---|
git add <file> | Stage a file |
git add . | Stage all changes |
git status | Show current status of the repo |
git commit -m "message" | Commit staged changes |
git commit -am "message" | Add & commit tracked files |
git rm <file> | Remove a file and stage the deletion |
git mv <old> <new> | Rename a file |
| Command | Usage |
|---|---|
git branch | List branches |
git branch <name> | Create a new branch |
git branch -d <name> | Delete a branch |
git checkout <branch> | Switch to a branch |
git checkout -b <branch> | Create and switch to a branch |
git switch <branch> | Modern way to switch branches |
git switch -c <branch> | Modern way to create + switch |
git merge <branch> | Merge a branch into current one |
git rebase <branch> | Reapply commits on top of another branch |
| Command | Usage |
|---|---|
git remote | List remotes |
git remote -v | List remote URLs |
git remote add origin <url> | Connect local repo to remote |
git remote remove <name> | Remove a remote |
git fetch | Download changes without merging |
git pull | Fetch + merge changes |
git pull --rebase | Fetch + rebase |
git push | Upload commits to remote |
git push -u origin <branch> | Push branch and set upstream |
| Command | Usage |
|---|---|
git log | Show commit history |
git log --oneline | Short commit history |
git log --graph --oneline | Visual commit tree |
git diff | Show unstaged changes |
git diff --staged | Show staged changes |
git show <commit> | Show specific commit details |
| Command | Usage |
|---|---|
git restore <file> | Undo unstaged changes |
git restore --staged <file> | Unstage a file |
git reset <file> | Unstage a file (older method) |
git reset --hard | Reset working directory + history |
git revert <commit> | Create new commit that undoes previous one |
git checkout <commit> | View past version (detached HEAD) |
| Command | Usage |
|---|---|
git stash | Temporarily save uncommitted changes |
git stash apply | Reapply latest stash |
git stash list | Show all stashes |
git stash drop | Delete a stash |
git stash pop | Apply + delete stash |
| Command | Usage |
|---|---|
git tag | List tags |
git tag <name> | Create a lightweight tag |
git tag -a <name> -m "message" | Create annotated tag |
git push --tags | Push tags to remote |
| Command | Usage |
|---|---|
.gitignore | File that tells Git what to ignore |
git rm -r --cached . | Reapply .gitignore to tracked files |
| Command | Usage |
|---|---|
| Manual editing | Resolve merge conflicts |
git mergetool | Use merge tool |
git rebase --continue | Continue after conflict fix |
git rebase --abort | Abort rebase |
| Command | Usage |
|---|---|
git cherry-pick <commit> | Apply specific commit onto another branch |
git bisect | Find bug-causing commit via binary search |
git blame <file> | Show who edited each line |
git clean -f | Remove untracked files |
git fsck | Verify repo integrity |
git gc | Clean up unnecessary files |
| Command | Usage |
|---|---|
git submodule add <url> | Add a submodule |
git submodule update | Update submodules |
git submodule init | Initialize submodules |
| Command | Usage |
|---|---|
git config --global alias.st status | Create git st alias |
git config --global alias.cm "commit -m" | Shortcut for commits |
Latest tech news and coding tips.
1. What Is the Golden Ratio? The Golden Ratio, represented by the Greek letter φ (phi), is…
In CSS, combinators define relationships between selectors. Instead of selecting elements individually, combinators allow you to target elements based…
Below is a comprehensive, beginner-friendly, yet deeply detailed guide to Boolean Algebra, complete with definitions, laws,…
Debugging your own code is hard enough — debugging someone else’s code is a whole…
Bubble Sort is one of the simplest sorting algorithms in computer science. Although it’s not…
In the world of software development—where new frameworks appear overnight, job titles evolve every three…