You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comprehensive guide covering essential Git commands and operations, including repository management, making changes, parallel development, syncing, configuration, and project management. Perfect for quick reference and detailed workflows.
Installation
Linux
Debian/Ubuntu
sudo apt-get update
sudo apt-get install git
Fedora
sudo dnf install git
Arch Linux
sudo pacman -S git
Windows
Using Git for Windows Installer
Download the Git for Windows installer from git-scm.com.
Run the installer and follow the instructions.
Using Chocolatey
choco install git
macOS
Using Homebrew
brew install git
Using MacPorts
sudo port install git
Using Xcode Kit (macOS)
Git comes pre-installed with Xcode.
Git Operations & Commands
1. Repository Setup
Operation
Command
Description
Init
git init
Create a new local git repository
Clone
git clone [Repo URL]
Create a copy of the original repository
Fork
git fork
Create a copy of the original repository on GitHub
Remove Init
rm -rf .git
Remove the .git directory
2. Committing Changes
Operation
Command
Description
Status
git status
Check the status of the current repository
Add
git add [file names]
Add single or multiple files to the staging area
git add .
Add all files to the staging area
Commit
git commit -m "[message]"
Commit the changes with a message
Log
git log
Show details of all commits
git log [Branch Name]
Show details of specific commits
Show
git show [Commit ID]
Show detailed information of a specific commit
Reset
git reset
Reset the HEAD to the last commit and discard new changes
git reset [file name]
Remove specific files from the staging area
git reset --soft HEAD~1
Undo the last commit but keep the changes staged
git reset --hard HEAD~1
Undo the last commit and discard the changes
Stash
git stash
Stash changes into the staging area
git stash list
Show all stash entries
git stash apply
Apply a stash
Clean
git clean -f
Remove untracked files from the working directory
git clean -fd
Remove untracked files and directories
Alias
git config --global alias.[alias] [command]
Shortened commands that map to longer commands
Tag
git tag [Tag Name]
Add a tag at a specific point for extra information