Home
/ How Tos
Git How Tos: Popular Git commands by category
Basics
Add file or directory to staging
Ignore files and directories
Provide a message with your commit
Show the status of the files in the current branch
Commit changes to the local repository
Create a new local repository
Clone an existing (remote) repository in the current directory
Show the current branch name and other information
Show whether the current branch is up-to-date, ahead or behind the remote branch
Track new or modified files
Add all files to staging
Move files
Branches
Create a branch and checkout (switch) to it
Delete local or remote branch
Delete local branch
Delete remote branch
List both local and remote branches
Switch to a different (existing) branch using "git checkout"
Create a new branch
List the available local branches
List only remote branches
List the available branches with details about the upstream branch and last commit message
Configuration
Edit the global configuration
Show the currently configured email address
Show the email address configured for a specific location (e.g. worktree, local, global, system)
Show the currently configured user name
Show the user name configured for a specific location (e.g. worktree, local, global, system)
Set the user name for all repositories
Set the email address for all repositories
Edit the local configuration
Set up the default text editor
Set the user name for the current repository
Set the email address for the current repository
Edit the system configuration
List all the configured variables
Associate Notepad++ as the default editor
Associate VisualStudio Code as the default text editor
Associate TextMate as the default editor
Associate Atom as the default text editor
Associate Sublime Text as the default editor
Diff
Show the changes of both staged and unstaged files since the last commit
Show the changes of files that are staged
Show the changes of files that are not yet staged for commit
Log
Show the log containing commit history
Show the latest N commits
Show the log, one line for each commit
Show the commits that affect a specific file or directory
Show a patch with changes introduced by each commit
Show the log as a graph
Filter the log entries by author name
Filter the log entries by committer name
Filter the log entries by date range
Filter the log entries by commit message containing a string
Merge
Merge branches
Finalize the merge commit after resolving conflicts
Mark the file as resolved after a merge conflict
Abort a merge
Resolve conflicts visually using a merge tool
Rebase the current branch
Cherry-pick commits
Remotes
Add remote repositories
Fetch data from a remote repository
Pull data from a remote repository
Push data to a remote repository
List the configured remotes
Show the configured remotes together with their URLs
Remove a remote
Rename a remote
Inspect a remote
Stash
Push files to stash
List the stash entries
Apply a stash entry to the current working tree
Pop a stash entry and apply its contents
Drop a stash entry from the stash list
Clear all the stash entries
Show the file modifications saved in the stash
Subtrees
Add a repository inside another repository (using subtrees)
Pull a subtree
Push a subtree
Undo
Revert a commit
Change the message and/or files of the last commit
Untrack files AND remove them from working tree
Untrack files from staging area, without removing them from the working tree
Unstage file using "git reset"
Unstage file using "git restore"
Revert file using "git checkout --"
Reset the staging area to a specific commit
Reset the working directory to the state of a specific commit
Revert a file using "git restore"