Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 

Repository files navigation

πŸš€ Git Commands Cheat Sheet

Welcome to your ultimate Git command reference – clean, categorized, and perfect for beginners and pros alike.

πŸ’‘ Use this cheat sheet to speed up your development workflow and master Git faster!


πŸ“Œ Setup and Configuration

git config --global user.name "Your Name"          # Set your name
git config --global user.email "you@example.com"   # Set your email
git config --global core.editor code               # Set VS Code as default editor
git config --list                                  # Show current config

πŸ—‚οΈ Repository Initialization

git init                       # Initialize new repo
git clone <repo-url>          # Clone a remote repo

πŸ“ Staging & Snapshots

git status                    # Check status of working directory
git add <file>                # Stage a file
git add .                     # Stage all changes
git reset <file>              # Unstage a file
git diff                      # View unstaged changes
git diff --staged             # View staged changes

πŸ’Ύ Committing

git commit -m "Message"       # Commit with message
git commit -am "Message"      # Add & commit tracked files

πŸ”„ Branching and Merging

git branch                    # List branches
git branch <branch>           # Create a new branch
git checkout <branch>         # Switch to branch
git checkout -b <branch>      # Create and switch
git merge <branch>            # Merge into current branch
git branch -d <branch>        # Delete a branch

🌐 Remote Repositories

git remote -v                       # List remotes
git remote add origin <url>         # Add remote repo
git push -u origin main             # Push local to remote
git push                            # Push updates
git pull                            # Pull latest changes
git fetch                           # Fetch without merge
git push --set-upstream main main   #links your local branch to the remote for future git push/git pull

πŸ•“ History & Logs

git log                       # Full history
git log --oneline             # Compact history
git show <commit>             # Show commit details
git blame <file>              # Who changed what

πŸ› οΈ Undoing Mistakes

git checkout -- <file>        # Discard local changes
git reset --hard              # Reset all to last commit
git reset --soft HEAD~1       # Undo last commit (keep changes)
git revert <commit>           # Revert a commit safely

πŸ“¦ Tagging Versions

git tag                       # List tags
git tag <tag>                 # Create tag
git push origin <tag>         # Push tag

🧹 Cleanup & Optimization

git clean -f                  # Remove untracked files
git gc                        # Garbage collection

πŸ” Authentication Helpers

git config --global credential.helper cache  # Cache credentials
git config --global credential.helper store  # Store credentials

βœ… Pro Tip

Use git help <command> for full docs on any command.


πŸ“„ License

This cheat sheet is open source and free to use. Contributions welcome!

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors