To integrate Git and GitHub with Visual Studio Code (VS Code), follow these steps:
1. *Install VS Code:*
If you haven't already, download and install Visual Studio Code from the official website: https://code.visualstudio.com/
2. *Install Git:*
Ensure Git is installed on your computer. You can download it from https://git-scm.com/downloads and follow the installation instructions.
3. *Open VS Code:*
Launch VS Code after installation.
4. *Install Git Extension:*
Inside VS Code, go to the Extensions view by clicking on the square icon on the left sidebar or pressing `Ctrl+Shift+X`. Search for "Git" and install the official Git extension provided by Microsoft.
5. *Configure Git:*
Open a terminal in VS Code (press `Ctrl+~` or go to ` Terminal`). Configure Git with your name and email:
```
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
```
6. *Initialize a Git Repository:*
If you have an existing project, navigate to its folder in VS Code. Otherwise, create a new folder for your project. Open a terminal in that folder and run:
```
git init
```
7. *Add Files to Repository:*
Use the following commands to add files to your Git repository and commit them:
```
git add .
git commit -m "Initial commit"
```
8. *Create a GitHub Repository:*
Go to GitHub (https://github.com/) and log in. Click the "+" sign in the upper right corner and select "New repository." Follow the instructions to create a new repository.
9. *Link Local Repository to GitHub:*
In VS Code's terminal, add the remote GitHub repository as a remote origin:
```
git remote add origin https://github.com/yourusername/your-...
```
Replace `yourusername` with your GitHub username and `your-repo-name` with the name of your GitHub repository.
10. *Push Your Code to GitHub:*
Push your local repository to GitHub using:
```
git push -u origin master
```
This command will push your code to the "master" branch on GitHub. If you're working with a different branch, replace "master" with the branch name.
11. *Authenticate with GitHub:*
If prompted, log in to your GitHub account to authenticate.
12. *GitHub Integration:*
After successfully pushing your code, you can now manage and track changes to your project on GitHub directly from VS Code.
That's it! You've successfully integrated Git and GitHub with Visual Studio Code. You can now collaborate with others, manage your version control, and easily work on your projects within the VS Code environment.