Skip to content

Latest commit

 

History

History
179 lines (111 loc) · 4.02 KB

File metadata and controls

179 lines (111 loc) · 4.02 KB

🚀 Getting Started with Git in VS Code

This guide helps you set up and use Git in Visual Studio Code (VS Code) with clear steps and tips.

🛠️ 1. Prerequisites

Before using Git in VS Code, make sure:

  • Git is installed on your system:
    👉 Download from https://git-scm.com
    👉 Check with:
    git --version

🔧 2. Configure Git (First Time Only)

Set your identity for commits:

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

(Optional) Set default branch name to main:

git config --global init.defaultBranch main

Check your config:

git config --list

🏗️ 3. Start a Git Project

➕ Create a New Git Repo

git init

This creates a .git folder to track your project.

📥 Clone an Existing Repo

git clone https://github.com/your_username/your_repo.git

💻 4. Use Git in VS Code

🧭 Open the Source Control Panel

Click the Source Control icon (or press Ctrl+Shift+G).

  • 📝 See changed files
  • ➕ Stage files
  • ✅ Commit with a message
  • 📤 Push to GitHub

You can also run Git commands in the Terminal (`Ctrl+``).


🔍 5. (Optional) Git Graph Extension

Install Git Graph from Extensions:

  • 🔎 Visualize commit history
  • 🌲 See branches clearly
  • 👇 Run Git Graph: View Git Graph from command palette (Ctrl+Shift+P)

📦 6. Typical Git Workflow

git status                # Check what's changed
git add .                 # Stage all changes
git commit -m "message"   # Save changes
git push origin main      # Upload to GitHub

🌐 7. Connect Local Repo to GitHub

git remote add origin https://github.com/your_username/your_repo.git
git push -u origin main

⚠️ 8. Tips & Best Practices

✅ Tip 💡 Description
Install Git first VS Code needs system Git
Always commit with a message Be clear and meaningful
Use .gitignore Avoid committing unwanted files
Use branches Don’t experiment on main
Avoid --force unless needed Can overwrite remote history
Commit often Small commits are easier to manage
Pull before push Avoid conflicts

🧯 9. Troubleshooting: "No source control providers registered"

If you see this message in VS Code:

"No source control providers registered"

It usually means one of the following:

  1. You didn't open a Git folder
    👉 Run git init in your project folder to start version control.

  2. Git is not installed
    👉 Install Git from https://git-scm.com

  3. Git is disabled in VS Code
    👉 Go to Settings → search git.enabled → make sure it's ✅ enabled.
    👉 Or check settings.json for this line and set it to true:

    "git.enabled": true
    
    

🐣 10. Beginner-Friendly Alternatives (No Terminal Required)

You don’t need to use the command line! Here are easier ways to manage Git:

✅ Use VS Code GUI Open your project folder in VS Code

Click the Source Control icon (left sidebar)

You'll see file changes

Click ➕ to stage, type a message, then click ✅ to commit

Click "..." → Push to upload to GitHub

VS Code handles the commands for you 👍

✅ Use GitHub Desktop If you prefer a full GUI:

Install from https://desktop.github.com

Clone or create repos with a few clicks

Stage, commit, and push without touching a terminal

Perfect for beginners and note-takers! 📓👩‍💻👨‍💻

🎉 Done!

Now you can work with Git and GitHub easily inside VS Code!

Happy coding! 💻🌈✨