# Basic Commands
# Initialize a new Git repository
git init
# Clone a repository into a new directory
git clone <repository_url>
# Show the working directory status
git status
# Add a file to the staging area
git add <file>
# Commit changes with a message
git commit -m "commit message"
# Show the commit history
git log
# Show changes between commits, commit and working tree, etc.
git diff
# Display help information about Git
git help
# Set the global username
git config --global user.name "Your Name"
# Set the global email address
# Intermediate Commands
# List all branches
git branch
# Create a new branch
git branch <branch_name>
# Switch to a different branch
git checkout <branch_name>
# Merge a branch into the current branch
git merge <branch_name>
# List remote repositories
git remote -v
# Fetch branches and commits from the remote repository
git fetch
# Fetch and merge changes from the remote repository
git pull
# Push changes to the remote repository
git push
# Remove a file from the working directory and staging area
git rm <file>
# Stash changes in the working directory
git stash
# Apply stashed changes
git stash pop
# Create a new tag
git tag <tag_name>
# Show various types of objects (commits, tags, etc.)
git show <commit>
# Advanced Commands
# Reapply commits on top of another base tip
git rebase <branch_name>
# Apply the changes introduced by some existing commits
git cherry-pick <commit>
# Revert a previous commit
git revert <commit>
# Reset current HEAD to the specified state
git reset <commit>
# Start binary search to find the commit that introduced a bug
git bisect start
# Mark the current commit as bad
git bisect bad
# Mark the current commit as good
git bisect good
# Show the reference logs
git reflog
# Rewrite branches with a filtered history
git filter-branch --tree-filter '<command>' HEAD
# Show what revision and author last modified each line of a file
git blame <file>
# Add a new submodule to the repository
git submodule add <repository_url>
# Cleanup unnecessary files and optimize the local repository
git gc