Basic Commands
| Name |
Syntax |
Description |
|
|
git init
|
git init [directory]
|
Initializes a new Git repository in the current (or specified) directory.
|
Details →
|
|
git clone
|
git clone <url> [directory]
|
Creates a local copy of a remote repository including all commits, branches, and history.
|
Details →
|
|
git add
|
git add <pathspec>
|
Stages changes for the next commit. Can add specific files, directories, or all changes.
|
Details →
|
|
git commit
|
git commit -m "message"
|
Records staged changes to the repository with a descriptive message.
|
Details →
|
|
git status
|
git status
|
Shows the state of the working directory and staging area. Lists tracked, untracked, and modified files.
|
Details →
|
|
git diff
|
git diff [options] [paths]
|
Shows changes between working directory, staging area, and commits.
|
Details →
|
Branching
| Name |
Syntax |
Description |
|
|
git branch
|
git branch [name] [options]
|
Lists, creates, or deletes branches. Without arguments, lists all local branches.
|
Details →
|
|
git checkout / git switch
|
git switch <branch> git checkout <branch>
|
Switch between branches. git switch is the modern command; git checkout also switches branches.
|
Details →
|
|
git merge
|
git merge <branch>
|
Merges the specified branch into the current branch. Creates a merge commit unless fast-forward.
|
Details →
|
|
git rebase
|
git rebase <base>
|
Reapplies commits on top of another base commit. Creates a cleaner linear history than merge.
|
Details →
|
|
git stash
|
git stash [push | pop | list | drop]
|
Temporarily saves uncommitted changes so you can switch branches without committing.
|
Details →
|
Remote Operations
| Name |
Syntax |
Description |
|
|
git remote
|
git remote [add | remove | -v]
|
Manages remote repository connections. origin is the conventional name for the primary remote.
|
Details →
|
|
git fetch / git pull
|
git fetch [remote] git pull [remote] [branch]
|
fetch downloads remote changes without merging; pull downloads and merges (fetch + merge).
|
Details →
|
|
git push
|
git push [remote] [branch]
|
Uploads local commits to the remote repository.
|
Details →
|
History & Inspection
| Name |
Syntax |
Description |
|
|
git log
|
git log [options] [paths]
|
Shows the commit history. Highly customizable with formatting and filtering options.
|
Details →
|
|
git show / git blame
|
git show <commit> git blame <file>
|
git show displays commit details; git blame shows who last modified each line of a file.
|
Details →
|
Advanced
| Name |
Syntax |
Description |
|
|
git reset
|
git reset [--soft | --mixed | --hard] <commit>
|
Moves HEAD and optionally the index/working directory to a previous state.
|
Details →
|
|
git revert
|
git revert <commit>
|
Creates a new commit that undoes changes from a specified commit. Safe for shared/public branches.
|
Details →
|
|
git cherry-pick
|
git cherry-pick <commit>
|
Applies the changes from a specific commit onto the current branch without merging the entire branch.
|
Details →
|
|
.gitignore
|
# patterns in .gitignore
|
A text file specifying intentionally untracked files/directories to ignore. Supports glob patterns.
|
Details →
|
No results found. Try a different search term.