Skip to content
Blog
Esc
  • Type at least two characters.
Browse Blog

History: GIT Cheat Sheet

Import from Docusaurus (blog/2025-02-12-git-cheat-sheet.mdx) (first version)

Back to history
Added: # GIT Cheat Sheet
Added:
Added: ### Setup
Added:
Added: - Set user details
Added:
Added: ```bash
Added: git config --global user.name "Your Name"
Added: ```
Added:
Added: ```bash
Added: git config --global user.email "your.email@example.com"
Added: ```
Added:
Added: - Check config
Added:
Added: ```bash
Added: git config --list
Added: ```
Added:
Added: ### Creating and Cloning Repositories
Added:
Added: - Initialize a new Git repository
Added:
Added: ```bash
Added: git init
Added: ```
Added:
Added: - Clone an existing repository
Added:
Added: ```bash
Added: git clone <repository-url>
Added: ```
Added:
Added: ### Basic Commands
Added:
Added: - Check the status of the working directory
Added:
Added: ```bash
Added: git status
Added: ```
Added:
Added: - Add files to staging area
Added:
Added: 1. Add specific file
Added:
Added: ```bash
Added: git add <file>
Added: ```
Added:
Added: 2. Add all files
Added:
Added: ```bash
Added: git add .
Added: ```
Added:
Added: - Commit changes
Added:
Added: ```bash
Added: git commit -m "Commit message"
Added: ```
Added:
Added: ### Branching and Merging
Added:
Added: - List branches
Added:
Added: ```bash
Added: git branch
Added: ```
Added:
Added: - Create a new branch
Added:
Added: ```bash
Added: git branch <branch-name>
Added: ```
Added:
Added: - Switch to a branch
Added:
Added: ```bash
Added: git checkout <branch-name>
Added: ```
Added:
Added: - Create and switch to a new branch
Added:
Added: ```bash
Added: git checkout -b <branch-name>
Added: ```
Added:
Added: - Merge a branch into the current branch
Added:
Added: ```bash
Added: git merge <branch-name>
Added: ```
Added:
Added: ### Remote Repositories
Added:
Added: - Add a remote repository
Added:
Added: ```bash
Added: git remote add origin <repository-url>
Added: ```
Added:
Added: - Push changes to remote
Added:
Added: ```bash
Added: git push origin <branch-name>
Added: ```
Added:
Added: - Pull latest changes from remote
Added:
Added: ```bash
Added: git pull origin <branch-name>
Added: ```
Added:
Added: ### Undoing Changes
Added:
Added: - Unstage a file
Added:
Added: ```bash
Added: git reset HEAD <file>
Added: ```
Added:
Added: - Discard local changes
Added:
Added: ```bash
Added: git checkout -- <file>
Added: ```
Added:
Added: - Revert a commit
Added:
Added: ```bash
Added: git revert <commit-hash>
Added: ```
Added:
Added: ### Log and History
Added:
Added: - Show commit history
Added:
Added: ```bash
Added: git log
Added: ```
Added:
Added: - Show commit history in one line
Added:
Added: ```bash
Added: git log --oneline
Added: ```
Added:
Added: ### Stashing
Added:
Added: ## Save uncommitted changes
Added:
Added: ```bash
Added: git stash
Added: ```
Added:
Added: - Apply the latest stashed changes
Added:
Added: ```bash
Added: git stash pop
Added: ```
Added:
Added: ### Tags
Added:
Added: - List all tags
Added:
Added: ```bash
Added: git tag
Added: ```
Added:
Added: - Create a new tag
Added:
Added: ```bash
Added: git tag -a v1.0 -m "Version 1.0"
Added: ```
Added:
Added: - Push tags to remote
Added:
Added: ```bash
Added: git push origin --tags
Added: ```
Added:
Added: ### Submodules
Added:
Added: - Add a submodule
Added:
Added: ```bash
Added: git submodule add <repository-url> <path>
Added: ```
Added:
Added: - Initialize submodules
Added:
Added: ```bash
Added: git submodule update --init --recursive
Added: ```
Added:
Added: ### Advanced Commands
Added:
Added: - Squash commits during interactive rebase
Added:
Added: ```bash
Added: git rebase -i HEAD~<number-of-commits>
Added: ```
Added:
Added: - Amend the last commit message
Added:
Added: ```bash
Added: git commit --amend -m "New commit message"
Added: ```
Added:
Added: - Hard reset to a specific commit
Added:
Added: ```bash
Added: git reset --hard <commit-hash>
Added: ```
Added:
Added: This cheat sheet provides a quick reference to essential Git commands for everyday development.