Comprehensive reference for every Git command from basic to advanced
Comprehensive reference for every Git command from basic to advanced
git config [--local|--global|--system] [<key> [<value>]]
Get and set repository or global options. Configure Git behavior, preferences, and user information.
# Set global user name and email
git config --global user.name "John Doe"
git config --global user.email "john@example.com"
# View all global settings
git config --global --list
# Set local repository settings
git config user.name "Jane Smith"
git config user.email "jane@work.com"
# Set default editor
git config --global core.editor "code --wait"
In VS Code, you can configure Git settings through the Settings UI (Ctrl+,) or by editing the .git/config file directly. The Source Control panel will reflect your configuration changes immediately.
git help [<command>|<guide>]
Display help information about Git or a specific Git command. Provides manual pages and guides.
# Show general help
git help
# Show help for a specific command
git help commit
# Show a conceptual guide
git help tutorial
# Show all available guides
git help -g
In VS Code, you can access Git help through the integrated terminal or by using extensions like GitLens. Press Ctrl+` to open the terminal and use git help commands directly.
git init [<directory>]
Create an empty Git repository or reinitialize an existing one. Initializes a .git directory with all necessary metadata.
# Initialize a new repository in current directory
git init
# Initialize a new repository in a specific directory
git init my-project
# Initialize with specific branch name (Git 2.28+)
git init -b main
In VS Code, you can initialize a Git repository through the Source Control panel. Click "Initialize Repository" when opening a folder that isn't already a Git repository.
git clone [<options>] [--] <repository> [<directory>]
Clone a repository into a new directory. Creates a local copy of a remote repository including all history and branches.
# Clone a repository into a new directory
git clone https://github.com/user/repo.git
# Clone into a specific directory
git clone https://github.com/user/repo.git my-local-folder
# Clone only the latest commit (shallow clone)
git clone --depth 1 https://github.com/user/repo.git
# Clone a specific branch
git clone -b branch-name https://github.com/user/repo.git
In VS Code, you can clone repositories through the Welcome screen or Command Palette. Use "Git: Clone" from the Command Palette (Ctrl+Shift+P) to clone a repository.
git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
[--edit | -e] [--all | -A] [--update | -u] [--renormalize]
[--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]
[--chmod=(+|-)x] [--] [<pathspec>...]
Add file contents to the index (staging area). Prepares changes for the next commit.
# Add a specific file
git add README.md
# Add all files in current directory
git add .
# Add all files with changes (tracked files only)
git add -u
# Add all files including new, modified, and deleted
git add -A
# Add files interactively
git add -i
# Add parts of a file interactively
git add -p
In VS Code, you can add files to the staging area through the Source Control panel. Click the + icon next to changed files or use the "Stage All Changes" button.
git status [<options>] [--] [<pathspec>...]
Show the working tree status. Displays paths that have differences between the index file and the current HEAD commit.
# Show status in long format
git status
# Show status in short format
git status -s
# Show status in branch format
git status -b
# Show status with ignored files
git status --ignored
In VS Code, the Source Control panel continuously shows the repository status. Changed files appear with colored badges indicating their status (M for modified, U for untracked, etc.).
Download the complete Git commands reference as a PDF for offline use.
Download PDFPractice these commands in our interactive Git Master Terminal.