Explore the A-Z of Git in just 2 minutes. This comprehensive tutorial covers all the essential Git commands and concepts.
Introduction
Are you ready to dive into the world of Git and become a version control pro? In just two minutes, we’ll cover the essential commands and concepts that will set you on the path to mastering Git. Buckle up, because this is your express journey through the A-Z of Git!
Core
git init
Initialize a new Git repository.
git clone
Clone a repository into a new directory.
git add
Add changes to the staging area.
git commit
Record changes to the repository.
git status
Show the status of changes.
git diff
View changes between commits.
git checkout
Switch branches or restore working tree files.
git reset
Reset the current HEAD to a specified state.
git log
Show the commit logs.
git show
Show various types of objects.
git tag
Create, list, delete, or verify a tag object.
git push
Update remote refs.
git pull
Fetch from and integrate with another repository or a local branch.
Branching
git branch
List, create, or delete branches.
git checkout -b
Create a new branch and switch to it.
git merge
Join two or more development histories together.
git rebase
Reapply commits on top of another base tip.
git branch --set-upstream-to
Set up a tracking relationship with a remote branch.
git branch --unset-upstream
Unset the upstream information.
git cherry-pick
Apply changes introduced by some existing commits.
Merging
git merge
Join two or more development histories together.
git rebase
Reapply commits on top of another base tip.
Stashing
git stash
Stash changes in a dirty working directory.
git stash pop
Apply the latest stash and remove it from the stash list.
git stash list
List all stashes.
git stash apply
Apply a specific stash.
git stash drop
Discard a specific stash.
Remotes
git remote
Manage set of tracked repositories.
git remote add
Add a remote repository.
git remote remove
Remove a remote repository.
git fetch
Download objects and refs from a remote repository.
git pull
Fetch from and integrate with another repository or a local branch.
git push
Update remote refs.
git clone --mirror
Create a bare mirror clone of a repository.
Configuration
git config
Get and set repository or global options.
git global config
Set a global configuration.
git reset config
Reset a specific configuration key.
Plumbing
git cat-file
Provide content or type and size information for repository objects.
git checkout-index
Copy files from the index to the working directory.
git commit-tree
Create a new commit object.
git diff-tree
Compares the content and mode of blobs found via two tree objects.
git for-each-ref
Output information on each ref.
Porcelain
git blame
Show what revision and author last modified each line of a file.
git bisect
Use binary search to find the commit that introduced a bug.
git checkout
Switch branches or restore working tree files.
git commit
Record changes to the repository.
git diff
Show changes between commits, commit and working tree, etc.
git fetch
Download objects and refs from another repository.
git grep
Print lines matching a pattern.
git log
Show the commit logs.
git merge
Join two or more development histories together.
git push
Update remote refs.
git rebase
Reapply commits on top of another base tip.
git reset
Reset the current HEAD to a specified state.
git show
Show various types of objects.
git tag
Create, list, delete, or verify a tag object.
Alias
git config --global alias.<alias> <command>
Create a shortcut for a Git command.
Hook
git config --local core.hooksPath <path>
Set the path to the directory where Git hooks are stored.
Experimental
(May not be fully Supported)
git annex
Manage files with Git, without checking the file contents into Git.
git describe
Show the most recent tag that is reachable from a commit.
git format-patch
Prepare patches for email submission.
git fsck
Verifies the connectivity and validity of the objects in the database.
git help
Display help information about Git commands.
git log --merges
Display commits with merge information.
git log --pretty=
Customize the format of commit logs.
git log --short-commit
Show only the first few characters of each commit SHA-1 hash.
git log --stat
Include statistics about the changes in each commit.
git log --topo-order
Display commits in topological order.
git merge-ours
Create a merge commit where the current branch declares which side of the merge should be considered.
git merge-recursive
Perform a recursive three-way merge.
git merge-subtree
Combine the histories of subtrees.
git mergetool
Run a merge conflict resolution tool.
git mktag
Create a tag object.
git patch-id
Compute a unique ID for a patch.
git p4
Import changes from a Perforce repository.
git prune
Remove objects that are no longer needed.
git pull --rebase
Fetch changes and reapply them on top of the current branch.
git push --mirror
Mirror all refs to another repository.
git push --tags
Push tags to a remote repository.
git reflog
Manage reflog information.
git replace
Create, list, or delete object replace refs.
git reset--hard
Reset the current branch to a specific commit, discarding changes.
git reset --mixed
Reset the current branch to a specific commit, keeping changes in the working directory.
git revert
Create a new commit that undoes changes made in a previous commit.
git rm
Remove files from the working directory and the index.
git show-branch
Show the branches containing a specific commit.
git show-ref --heads
Display references that are heads (branch tips).
git show-ref --tags
Display references that are tags.
git stash save
Save working directory and index in a new stash.
git subtree
Merge subtrees together.
git tag --delete
Delete tags.
git tag --force
Replace an existing tag with a new one.
git tag --sign
Create a signed tag.
git tag --verify
Verify the GPG signature of tags.
git unpack-file
Creates a temporary file with the contents of a blob.
git update-index
Register file contents in the working directory and index.
git verify-pack
Verify the connectivity and validity of the objects in the database.
Congratulations! You’ve just completed a comprehensive crash course in Git commands. Explore and practice these commands regularly to solidify your Git skills. With the right knowledge and resources, you’re well on your way to becoming a Git expert! 🚀