SyntaxStudy
Sign Up
Home Git Reference

Git Reference

20 entries — click any item for full details and examples

Basic Commands

Name Description
git init Initializes a new Git repository in the current (or specified) directory.
git clone Creates a local copy of a remote repository including all commits, branches, and history.
git add Stages changes for the next commit. Can add specific files, directories, or all changes.
git commit Records staged changes to the repository with a descriptive message.
git status Shows the state of the working directory and staging area. Lists tracked, untracked, and modified files.
git diff Shows changes between working directory, staging area, and commits.

Branching

Name Description
git branch Lists, creates, or deletes branches. Without arguments, lists all local branches.
git checkout / git switch Switch between branches. git switch is the modern command; git checkout also switches branches.
git merge Merges the specified branch into the current branch. Creates a merge commit unless fast-forward.
git rebase Reapplies commits on top of another base commit. Creates a cleaner linear history than merge.
git stash Temporarily saves uncommitted changes so you can switch branches without committing.

Remote Operations

Name Description
git remote Manages remote repository connections. origin is the conventional name for the primary remote.
git fetch / git pull fetch downloads remote changes without merging; pull downloads and merges (fetch + merge).
git push Uploads local commits to the remote repository.

History & Inspection

Name Description
git log Shows the commit history. Highly customizable with formatting and filtering options.
git show / git blame git show displays commit details; git blame shows who last modified each line of a file.

Advanced

Name Description
git reset Moves HEAD and optionally the index/working directory to a previous state.
git revert Creates a new commit that undoes changes from a specified commit. Safe for shared/public branches.
git cherry-pick Applies the changes from a specific commit onto the current branch without merging the entire branch.
.gitignore A text file specifying intentionally untracked files/directories to ignore. Supports glob patterns.