Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
FAQs Support
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials
Git

Git VCS Quick Overview

The world's most popular distributed version control system — designed by Linus Torvalds for tracking changes in source code.

Free & Open Source Distributed Version Control

What is Git?

Git is a free, open-source distributed version control system (VCS) designed by Linus Torvalds in 2005. It tracks changes in source code during software development and enables multiple developers to collaborate efficiently on projects of any size.

Unlike centralized VCS tools, every Git clone is a full repository with complete history — making it fast, reliable, and offline-capable.

Git Commands Cheatsheet

Setup & Configuration

Terminal
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global core.editor "code --wait"   # VS Code as editor
git config --list                                # View all config

Creating & Cloning

Terminal
git init                        # Initialize new repository
git clone             # Clone existing repository
git clone  my-folder  # Clone into specific folder

Staging & Committing

Terminal
git status                          # Show working directory status
git add                       # Stage a specific file
git add .                           # Stage all changes
git add -p                          # Stage changes interactively
git commit -m "message"             # Commit staged changes
git commit -am "message"            # Stage tracked files and commit
git commit --amend                  # Modify the last commit

Branching

Terminal
git branch                          # List local branches
git branch -a                       # List all branches (local + remote)
git branch                    # Create new branch
git checkout                  # Switch to branch
git checkout -b               # Create and switch to branch
git switch                    # Switch branch (modern syntax)
git switch -c                 # Create and switch (modern syntax)
git branch -d                 # Delete merged branch
git branch -D                 # Force delete branch
git merge                   # Merge branch into current
git rebase                  # Rebase current onto branch

Remote Repositories

Terminal
git remote -v                           # List remotes with URLs
git remote add origin              # Add remote
git remote set-url origin          # Change remote URL
git push origin                 # Push branch to remote
git push -u origin              # Push and set upstream
git pull                                # Fetch and merge
git fetch                               # Fetch without merging
git pull --rebase                       # Pull with rebase

History & Diff

Terminal
git log                             # Full commit history
git log --oneline --graph           # Compact graph view
git log --author="Name"             # Filter by author
git diff                            # Unstaged changes
git diff --staged                   # Staged changes
git blame                     # Who changed each line
git show                    # Show commit details

Undoing Changes

Terminal
git restore                   # Discard working directory changes
git restore --staged          # Unstage a file
git reset --soft HEAD~1             # Undo last commit, keep changes staged
git reset --mixed HEAD~1            # Undo last commit, keep changes unstaged
git reset --hard HEAD~1             # Undo last commit, discard changes
git revert                  # Create new commit that undoes a commit

Stashing

Terminal
git stash                           # Stash current changes
git stash push -m "description"     # Stash with a message
git stash list                      # List all stashes
git stash pop                       # Apply latest stash and remove it
git stash apply stash@{0}           # Apply specific stash
git stash drop stash@{0}            # Delete specific stash

Tags

Terminal
git tag                             # List tags
git tag v1.0.0                      # Create lightweight tag
git tag -a v1.0.0 -m "Release"      # Create annotated tag
git push origin v1.0.0              # Push tag to remote
git push --tags                     # Push all tags

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.