Git Command Reference
Daily Git commands for version control, branch management, undo operations, and collaboration workflows
Command List
- git add Stage file changes for the next commit
- git commit Record staged changes as a commit
- git push Push local commits to a remote repository
- git pull Pull and merge changes from a remote repository into the current branch
- git branch Manage branches: create, list, rename, and delete branches
- git cherry-pick Apply specific commits to the current branch without merging the entire branch
- git tag Create tags for specific commits, typically used to mark release versions
- git remote Manage remote repository connections: add, remove, rename, and view remotes
- git fetch Download latest commits and branch info from remote without auto-merging into local branches
- git diff Show file differences between working directory, staging area, and commits
- git blame Show who last modified each line of a file and when
- git bisect Use binary search to quickly find the commit that introduced a bug
- git clean Remove untracked files and directories from the working directory
- git reflog Record all changes to HEAD and branch references, useful for recovering lost commits
- git worktree Check out multiple branches into different directories simultaneously without switching or stashing
- git submodule Embed another Git repository as a subdirectory within a Git repository
- git archive Package project files of a specific version as tar or zip archive, excluding .git directory
- git shortlog Summarize commits grouped by author, commonly used for changelogs and contributor statistics
- git show Show detailed information about a specific commit, including metadata and file changes
Common Scenarios
- How to Undo a Git Commit? Committed but found issues, want to undo the last one or more commits
- How to Resolve Git Merge Conflicts? Got CONFLICT during merge or rebase, not sure how to handle it
- How to Roll Back to a Previous Git Version? Code has issues, want to go back to a previous working version
Comparisons
- git merge vs git rebase: When to Use Which? merge preserves full branch history, rebase produces linear history