📝

Git Commands Reference

Comprehensive Git commands reference guide. Quick lookup for Git commands, syntax, and usage examples.

Practical Guide
Git Commands
Basic Operations14
CommandUsage
git init [repository-name]
Initialize a new Git repository
git init [repository-name]
git clone <repository-url>
Clone a remote repository locally
git clone <repository-url>
git status
View current branch status
git status
git diff
View tracked file changes
git diff
git add <file>
Add specified file to staging area
git add <file>
git add .
Add all modified files to staging area
git add .
git commit -a
Commit all local modifications
git commit -a
git commit -m "xxx"
Commit files added to staging area with xxx as commit message
git commit -m "xxx"
git commit --amend -m "xxx"
Modify last commit (do not use to modify published commits)
git commit --amend -m "xxx"
git commit -am "xxx"
Shortcut for git add . and git commit -m "xxx"
git commit -am "xxx"
git stash
Stash current modifications, set all to HEAD state
git stash
git stash list
View all stash list
git stash list
git stash push
Stash current working directory files to temporary space
git stash push
git stash pop
Restore files from temporary space to current working directory
git stash pop
Commit History8
CommandUsage
git log
View commit log
git log
git log -n
Show n lines of log, where n is an integer
git log -n
git log --stat
View local commit log
git log --stat
git show <commit>
View commit log and related changed files
git show <commit>
git show HEAD
View HEAD commit log
git show HEAD
git show HEAD^
View HEAD^ commit log
git show HEAD^
git blame <file>
View the last modifier for each line of a file
git blame <file>
git whatchanged
Show commit history and changed files
git whatchanged
Branches & Tags16
CommandUsage
git branch
View local branches
git branch
git branch -r
View remote branches
git branch -r
git branch -a
View all branches (local and remote)
git branch -a
git branch --merged
View branches merged to current branch
git branch --merged
git branch --no-merged
View branches not merged to current branch
git branch --no-merged
git branch -m <new-branch>
Rename current branch to new-branch
git branch -m <new-branch>
git branch -M <new-branch>
Force rename current branch to new-branch
git branch -M <new-branch>
git branch -m <old-branch> <new-branch>
Rename old-branch to new-branch
git branch -m <old-branch> <new-branch>
git branch -M <old-branch> <new-branch>
Force rename old-branch to new-branch
git branch -M <old-branch> <new-branch>
git checkout <branch-name>
Switch to specified branch
git checkout <branch-name>
git branch <new-branch>
Create new branch
git branch <new-branch>
git branch --track <new> <remote>
Create and track remote branch
git branch --track <new> <remote>
git branch -d <branch-name>
Delete local branch
git branch -d <branch-name>
git tag
List all local tags
git tag
git tag <tag-name>
Create tag based on latest commit
git tag <tag-name>
git tag -d <tag-name>
Delete tag
git tag -d <tag-name>
Remove Commands3
CommandUsage
git rm <file>
Remove file from working directory and staging area
git rm <file>
git rm -r <directory>
Recursively remove directory
git rm -r <directory>
git rm --cached <file>
Stop tracking file, do not delete from disk
git rm --cached <file>
Merge & Rebase6
CommandUsage
git merge <branch>
Merge specified branch to current branch
git merge <branch>
git rebase <branch>
Rebase current branch onto specified branch
git rebase <branch>
git rebase --abort
Abort ongoing rebase operation
git rebase --abort
git rebase --continue
Continue rebase after resolving conflicts
git rebase --continue
git mergetool
Use configured mergetool to resolve conflicts
git mergetool
git add <resolved-file> git rm <resolved-file>
Manually resolve merge conflicts
git add <resolved-file> git rm <resolved-file>
Undo Commands11
CommandUsage
git reset --hard HEAD
Reset to HEAD, discard all changes
git reset --hard HEAD
git reset <commit>
Reset to specified commit
git reset <commit>
git reset --hard <commit>
Force reset to specified commit, discard all changes
git reset --hard <commit>
git reset --merge <commit>
Reset merge operation
git reset --merge <commit>
git reset --keep <commit>
Reset but keep uncommitted local changes
git reset --keep <commit>
git revert <commit>
Revert specified commit
git revert <commit>
git restore <file>
Restore file to last committed state
git restore <file>
git checkout -- <file>
Same as git restore <file>
git checkout -- <file>
git checkout HEAD <file>
Restore file from HEAD
git checkout HEAD <file>
git clean
Remove untracked files from working directory
git clean
git clean -n
Preview files to be deleted
git clean -n
Remote Operations3
CommandUsage
git remote add origin <url>
Manage remote repositories
git remote add origin <url>
git push origin [branch-name]
Push to remote repository
git push origin [branch-name]
git pull origin [branch-name]
Pull updates from remote repository
git pull origin [branch-name]
Git Configuration7
CommandUsage
git config --list
List all Git configuration
git config --list
git config --global user.name <name>
Set user name for commits
git config --global user.name <name>
git config --global user.email <email>
Set user email for commits
git config --global user.email <email>
git config --global alias.<alias> <command>
Create global alias for Git commands
git config --global alias.<alias> <command>
git config --system core.editor <editor>
Set default editor for all users
git config --system core.editor <editor>
git config --global --edit
Open global config file in editor
git config --global --edit
git config --global color.ui auto
Enable colored output for Git commands
git config --global color.ui auto
Other Commands2
CommandUsage
git var -l
List Git environment variables
git var -l
git help <command>
Show help for specified command
git help <command>
Related Terms
Below are common Git terms that will help you better understand the Git version control system.
Git:Git: An open-source, distributed version control system
Commit:Commit: A Git object that represents a snapshot of the entire repository as a SHA
Branch:Branch: A lightweight, movable pointer to a commit
Clone:Clone: Creating a local copy of a remote repository
Remote:Remote: A repository hosted on GitHub, GitLab, etc., where all team members can submit modifications
Fork:Fork: Creating a copy of another user's repository
Pull Request:Pull Request (PR): A request for others to pull and merge your changes to a repository
HEAD:HEAD: Represents the current working directory, can be switched using git checkout

❓What is Git Commands Reference

Git command reference and cheat sheet providing quick access to common Git commands, workflows, and best practices for version control.

✨Features

🚀

Comprehensive Git commands reference with syntax examples

Complete Git commands reference with syntax examples, usage instructions, and practical scenarios covering all aspects of version control.
⚡

Categorized commands for easy navigation and learning

Commands organized by category including basic operations, branch management, remote operations, undo operations, tagging, and configuration for easy navigation.
🎯

Copy-to-clipboard functionality for quick command usage

One-click copy-to-clipboard functionality for any Git command, enabling you to quickly paste and execute commands in your terminal.
🔒

Search functionality to find specific commands quickly

Real-time search functionality to quickly find specific Git commands by name, description, or usage, improving your workflow efficiency.

🎯Use Cases

Development workflow

Use Git Commands Reference during implementation to generate, inspect, format, or verify technical assets without switching to heavier project tooling.

Code review and cleanup

Git Commands Reference helps review copied snippets, generated files, configuration fragments, and implementation details before they are committed or shared.

Technical documentation

Turn practical examples from Git Commands Reference into clearer pull requests, runbooks, onboarding notes, and API or SDK documentation.

📚Practical Guide

What is Git Version Control

Git is a distributed version control system that tracks changes in source code during software development. It allows multiple developers to work on the same project simultaneously, maintains a complete history of changes, and enables branching and merging workflows. Git uses a three-tree architecture (Working Directory, Staging Area, Repository) and stores data as snapshots rather than file differences.

Git Command Structure and Syntax

Git commands follow a consistent structure: 'git <command> [options] [arguments]'. The system includes over 100 commands organized into categories like basic operations, branching, merging, remote operations, and advanced features. Each command has specific syntax rules, optional parameters, and usage patterns. Advanced features include command aliases, custom commands, and integration with external tools.

Command Search and Reference Systems

Git command reference tools use sophisticated search algorithms to provide quick access to command information, syntax, and examples. The system includes full-text search, category filtering, command completion, and intelligent suggestions. Advanced features include fuzzy matching, command history, and integration with development environments. The implementation ensures fast search performance, accurate results, and

Developer Workflow and Learning Applications

Git command reference tools are essential for developer education, workflow optimization, and productivity enhancement. Applications include learning Git fundamentals, command syntax reference, workflow automation, and team collaboration. The tools support various skill levels, provide interactive learning experiences, and integrate with development environments. Advanced features include command execution, workflow templates, and integration with

💬Frequently Asked Questions

❓What is Git command reference?
Git command reference is a comprehensive tool that provides quick lookup, descriptions, and usage examples for all common Git commands. It helps developers quickly find and understand how to use Git commands.
💬How do I search for a specific Git command?
You can use the search box at the top of the page to enter command names, descriptions, or usage keywords. The tool will filter and display matching commands in real-time.
🔍How do I copy a Git command?
There is a copy icon on the right side of each command line. Click it to copy the command to your clipboard. You can also click the copy button in the command table.
💡How are commands categorized?
Commands are categorized by function, including basic operations, commit history, branches and tags, remove commands, merge and rebase, undo commands, remote operations, Git configuration, and other commands.
📚Does this tool include all Git commands?
This tool includes the most commonly used Git commands and common options. Git has over 100 commands, and this tool focuses on the most frequently used commands in daily development.
🎯How can I learn to use these Git commands?
You can browse commands in each category and view descriptions and usage examples for each command. It is recommended to start with basic operations and gradually learn advanced features like branch management and merge operations.
✨Do command descriptions include all options?
Each command includes the most commonly used usage and options. For more detailed option descriptions, it is recommended to check the official Git documentation or use the git help <command> command.
🌟Can I use this tool offline?
Yes, this tool runs completely in the browser and does not require an internet connection to view and copy Git commands. However, an internet connection is required to load resources on first use.

💡How To & Tips

1️⃣

Browse or search Git commands

Browse categorized Git commands or use the search function to quickly find the commands you need.
2️⃣

View command descriptions and usage

Click on a command to see detailed descriptions and usage examples, and learn how to use the command correctly.
3️⃣

Copy commands to clipboard

Click the copy button to copy the command to your clipboard for use in the terminal.
4️⃣

Execute commands in terminal

Paste the copied command into your terminal and execute it to complete your Git operations.

User Comments

0 / 2000
Loading...