🧠 GIT CHEATSHEET for CVS Users

🧠 GIT CHEATSHEET for CVS Users

πŸ”§ Setup

bashCopyEditgit config --global user.name "Your Name"
git config --global user.email "you@example.com"

πŸ—‚οΈ Start a New Repo

bashCopyEditgit init               # Start new repo
git clone git@host:user/repo.git  # Clone via SSH

πŸ“ Staging & Committing

bashCopyEditgit status             # Show changes
git add file.txt       # Stage a file
git add .              # Stage all
git commit -m "Message"  # Commit

πŸ”„ Syncing with Remote

bashCopyEditgit pull               # Fetch + merge
git push               # Push changes

🌳 Branching

bashCopyEditgit branch             # List branches
git branch new-branch  # Create branch
git checkout new-branch  # Switch
git switch -c new-branch  # Create + switch (modern)
git merge branch-name  # Merge into current

🧹 Undo & Cleanup

bashCopyEditgit reset HEAD file.txt    # Unstage
git checkout -- file.txt   # Discard changes
git restore file.txt       # (modern syntax)

πŸ“œ Log & Diff

bashCopyEditgit log --oneline          # Compact history
git diff                   # Show unstaged diffs
git diff --cached          # Staged diffs

πŸ’₯ Danger Zone

bashCopyEditgit reset --hard HEAD     # Reset all changes
git clean -fd             # Delete untracked files

πŸ›°οΈ Remote via SSH

bashCopyEditgit remote -v                            # View remotes
git remote add origin git@host:repo.git  # Add remote
git push -u origin main                  # First push

Leave a Comment

Your email address will not be published. Required fields are marked *