Used to initialize a new Git repository in your current directory. It creates a hidden .git folder where all the metadata is stored.
git init
Creates a local copy of a remote repository. Perfect for contributing to existing projects.
git clone <repository-url>
Shows the status of changes as untracked, modified, or staged. Helps you know what’s going on.
git status
Adds files to the staging area before committing. You can add individual files or all changes.
git add <filename>
git add .
Creates a snapshot of the staged changes with a message. It’s like saving your project.
git commit -m "your message"
Sends your commits from your local repo to a remote one like GitHub.
git push origin main
Fetches and integrates changes from a remote repo into your current branch.
git pull
Lists all branches or creates a new one. Great for working on different features independently.
git branch
git branch <branch-name>
Switches between branches or restores working directory files. Useful for navigating versions.
git checkout <branch-name>
Merges the changes from another branch into your current branch. Commonly used in feature integrations.
git merge <branch-name>
Resets the current HEAD to the specified state.
git reset --hard HEAD~1
Configures Git settings like username and email globally or locally.
git config --global user.name "Your Name"
Lists remote connections for your repository.
git remote -v
Downloads commits, files, and refs from a remote repository.
git fetch
Displays the commit history of the current branch.
git log
Shows changes between commits, commit and working tree, etc.
git diff
Deletes tracked files from the working directory and stages the removal.
git rm <filename>
Moves or renames a file or directory.
git mv oldname.txt newname.txt
Saves your changes temporarily without committing them.
git stash
Applies the most recently stashed changes and removes them from the stash list.
git stash pop
Tags a specific commit, useful for marking release points.
git tag v1.0
Applies the changes from a specific commit to the current branch.
git cherry-pick <commit-hash>
Reverts a previous commit by creating a new one.
git revert <commit-hash>
Removes untracked files from your working directory.
git clean -f
Shows who made each change to a file and when.
git blame <file>
Summarizes git log output by author.
git shortlog
Displays information about a commit, tag, or other git object.
git show <commit-hash>
Creates a tar or zip archive of files in the repo.
git archive --format=zip HEAD > latest.zip
Reapplies commits on top of another base tip.
git rebase main
Shows the history of all HEAD changes.
git reflog