0% found this document useful (0 votes)
6 views2 pages

Git Commands CheatSheet

The document provides a comprehensive list of essential Git commands categorized into basic commands, branching and merging, remote repositories, undo/reset/fix, and extra helpful commands. Each command is accompanied by a brief explanation of its function. This serves as a quick reference guide for users to effectively manage their Git repositories.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Git Commands CheatSheet

The document provides a comprehensive list of essential Git commands categorized into basic commands, branching and merging, remote repositories, undo/reset/fix, and extra helpful commands. Each command is accompanied by a brief explanation of its function. This serves as a quick reference guide for users to effectively manage their Git repositories.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Essential Git Commands with Explanation

Basic Git Commands

git init - Initialize a new Git repository

git clone <url> - Clone a repository into a new directory

git status - Show the working tree status

git add <file> - Add file contents to the index (staging)

git add . - Add all files to staging

git commit -m "" - Commit staged changes with a message

git log - Show commit logs

git config - Set Git configuration (username/email)

Branching & Merging

git branch - List branches

git branch <name> - Create a new branch

git checkout <name>- Switch to a branch

git switch <name> - Modern alternative to checkout

git merge <branch> - Merge a branch into current branch

Remote Repositories

git remote -v - Show remote URLs

git remote add origin <url> - Add a remote repository

git push -u origin main - Push first commit and set upstream

git push - Push local commits to remote

git pull - Fetch and merge changes from remote

git fetch - Download changes without merging

Undo / Reset / Fix


Essential Git Commands with Explanation

git restore <file> - Restore file to last committed state

git reset - Unstage a file

git revert <commit> - Revert a specific commit

git stash - Save current changes temporarily

git stash pop - Apply stashed changes

Extra Helpful Commands

git show - Show details of last commit

git diff - Show changes between commits/files

git tag - Create a version tag (e.g., v1.0.0)

git cherry-pick <commit> - Apply changes from a specific commit

git rm <file> - Delete file from working directory and Git

You might also like