🎯 First Things First: Getting Started

(Because everyone needs to start somewhere, right?)

📝 Setting Up Your Identity

git config --global user.name "Your Awesome Name"
git config --global user.email "your.epic@email.com"

💡 Why? Because Git needs to know who to blame when something goes wrong! (Just kidding… )

🌟 The Daily Commands (Your New Best Friends)

git init
git commit -m "first commit"
git branch -M main
git remote add origin YOUR_REPOSITORY_URL
git push -u origin main

🔍 Checking Status

git status

💡 When to use: When you’re like “What did I even change?” (Trust me, you’ll use this A LOT)

📦 Staging Changes

git add filename.txt    # Stage a specific file
git add .              # Stage everything (YOLO style!)

💡 Pro tip: Think of staging as putting your stuff in a box before shipping. You don’t want to accidentally ship your cat! 🐱

💾 Committing Changes

git commit -m "Add awesome new feature"

💡 Writing good commit messages:

  • ❌ “Fixed stuff” (Bad! What stuff?)
  • ❌ “AAAAAAHHHHHHH!” (We’ve all been there, but no)
  • ✅ “Add user authentication to login page” (Perfect!)

Using Git with an empty commit:

git commit --allow-empty -m "Trigger deployment"
git push origin main    # or whatever your branch name is

💡 Pro tip: This is the cleanest way - it creates an empty commit and pushes it to trigger a new deployment without changing any files.

🌳 Branching Out (Like a Tree, But Cooler)

🌳 Branching and Feature Development Workflow

🌿 Creating & Managing Feature Branches

# Start from main branch
git checkout main

# Create and switch to feature branch (do this before making changes!)
git checkout -b feature/descriptive-name     # Use descriptive names like 'feature/copy-button'

# Work on your changes...
git add .
git commit -m "Add feature description"
git push origin feature/descriptive-name

💡 Best Practice: Always create a new branch for new features - this keeps your main branch clean and stable!

🤝 Pull Request Workflow (Even for Personal Projects!)

  1. Push your feature branch to GitHub
  2. Go to GitHub repository
  3. Click “Compare & Pull Request”
  4. Write clear title and description
  5. Review your own code
  6. Merge the pull request
  7. Delete the branch after merging

💡 Why PR for personal projects?

  • Maintains clean development history
  • Forces code review (even self-review!)
  • Builds good habits for team projects
  • Documents feature additions

🧹 Cleaning Up After Merge

# After PR is merged on GitHub:

# 1. Switch back to main
git checkout main

# 2. Pull the merged changes
git pull origin main

# 3. Delete local feature branch
git branch -d feature/descriptive-name

# 4. Delete remote branch (if not done through GitHub UI)
git push origin --delete feature/descriptive-name

💡 Important: Always pull changes to local main branch after merging on GitHub before deleting branches!

🚨 Common Branch Management Warnings

🤝 Playing Nice with Others (Social Git-iquette)

📥 Cloning a Repository

git clone https://github.com/username/repo-name.git

💡 What’s happening: You’re basically saying “I want a copy of that awesome code, please!”

🔄 Pulling Updates

git pull origin main

💡 When to pull: Before you start working (unless you enjoy fixing merge conflicts 😅)

📤 Pushing Changes

git push origin branch-name

💡 Remember: Push with confidence, but maybe test your code first? Just a thought!

🆘 Oops! (Because We All Make Mistakes)

😱 Undoing Last Commit

git reset --soft HEAD~1    # Undo commit but keep changes
git reset --hard HEAD~1    # Undo commit and delete changes (danger zone!)

💡 When to use: When you accidentally commit your shopping list or passwords (we’ve all been there)

🔄 Reverting Changes in a File

git checkout -- filename

💡 Use case: When you’ve been staring at your code for so long that you’ve made it worse

🌟 GitHub Pull Request Workflow (Be a Team Player)

  1. Create a branch for your feature
  2. Make your changes
  3. Push to GitHub
  4. Create Pull Request
  5. Wait for reviews (maybe make coffee?)
  6. Address feedback
  7. Get approved
  8. Merge and celebrate! 🎉

💡 Pro tip: Pull Requests are like showing your mom your homework before turning it in - get feedback before it’s too late!

🎯 Best Practices (The “Please Do This” Section)

  1. Branch Often: Keep your branches small and focused

    Like mini-tasks, not your entire todo list!

  2. Commit Regularly: Small, logical commits are better than one giant commit

    Think bite-sized pieces, not an entire pizza in one bite

  3. Pull Before Push: Always pull the latest changes before pushing

    Avoid the dreaded merge conflicts!

  4. Write Good Commit Messages: Future you will thank present you

    Your commit messages tell a story - make it a good one!

  5. Use .gitignore: Keep your repository clean

    Nobody needs to see your node_modules folder 😉

🚫 Common Mistakes to Avoid (Learn from Others’ Pain)

  1. Committing directly to main branch

    “Living dangerously” is for action movies, not version control

  2. Not pulling before starting new work

    Unless you enjoy fixing merge conflicts…

  3. Pushing sensitive information

    Your AWS keys don’t belong on GitHub (trust me on this one)

  4. Not using branches for features

    Main branch should be like a good TV show - stable and reliable

🎉 Final Tips

💡 The Most Important Rule: Don’t be afraid to experiment (in a new branch, of course!)

🆘 When All Else Fails

rm -rf repo-name
git clone https://github.com/username/repo-name.git

The nuclear option - sometimes starting fresh is the best solution!

Additional note: In PowerShell, you can combine multiple commands using a semicolon (;) or by using &&, where && will only execute the next command if the previous one succeeds.

Here’s the combined command using &&:

git add . && git commit -m "test" && git push origin main

Or using semicolons:

git add .; git commit -m "test"; git push origin main

The && approach is generally preferred because it will stop if any command fails, preventing potential issues (like pushing a failed commit). If any command in the chain fails, the subsequent commands won’t execute.


Happy coding!