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! πŸ’»πŸŒˆβœ¨