🖥️

Integrating Git and GitHub in VS Code

Aug 10, 2024

Git and GitHub Integration with Visual Studio Code

Overview

  • Tutorial for integrating Git and GitHub into a workflow with Visual Studio Code.
  • Focus on getting started with Git and VS Code.
  • Future tutorials will dive deeper into Git details.

Installation

Installing Git

  1. Visit git-scm.com.
  2. Download Git for your operating system (Windows, macOS, or Linux).
  3. Installing Git also installs Git Bash, a terminal for Git.

Installing Visual Studio Code

  1. Visit code.visualstudio.com.
  2. Download Visual Studio Code for your operating system.

Setting Up a Project

  1. Create an Example Project Folder:
    • Open the folder in Visual Studio Code.
    • Open Git Bash in the folder via right-click.
  2. Using Git Bash in Visual Studio Code:
    • Open Visual Studio Code's terminal (Terminal > New Terminal).
    • Set Git Bash as the default shell.

Initializing Git

  1. Run the command git init in the terminal to initialize a new Git repository.
  2. Check the status with git status:
    • Displays current branch (master), untracked files, and changes.
  3. Stage changes with git add . (period adds all changes).
  4. Commit changes with git commit -m "first commit".
  5. Check status again to confirm working tree is clean.

Making Changes

  1. Add content to index.html.
    • Save the file; observe changes in color (amber for modified).
  2. Stage and commit changes as needed.
    • Example: git add ., git commit -m "added paragraph".

Linking to GitHub

  1. Create a GitHub Account:
  2. Create a New Repository:
    • Click "New" on GitHub, name your repository (e.g., git-example-project).
    • Set visibility to public, click "Create repository".
  3. Link Local Repository to GitHub:
    • Copy commands provided by GitHub to link and push local changes:
      • git remote add origin <repository-url>
      • git push -u origin master
    • This uploads local commits to GitHub.

Making Further Changes

  1. Modify index.html again and add new file page2.html.
  2. Stage and commit these changes.
    • Use git add . and git commit -m "message".
  3. Push changes to GitHub with git push.

Summary

  • You can view commit history and changes on GitHub.
  • Process includes creating a local repo, linking to GitHub, and pushing changes.
  • Future tutorials will cover more advanced Git features.

Conclusion

  • Reminder to focus on progress, not perfection.
  • Encourage subscribing for future tutorials.