Setting Up Git and GitHub with VS Code
October 14th, 2024 1:20 PM Mr. Q Categories: Windows 11
If you’re looking to streamline your development process with Git and GitHub in Visual Studio Code, this guide will help you uninstall any previous installations, set up the latest tools, and walk you through cloning a repository and making your first commit.
Step 1: Uninstall Existing Git and GitHub Programs, & Credentials
Before installing the new versions, it’s a good idea to remove any previous installations that may cause conflicts. Here’s how to do that:
- Uninstall Programs:
- Open the Control Panel: Search for “Control Panel” in the Windows search bar.
- Uninstall any existing Git and GitHub programs.
- Remove Credentials:
- Navigate to Credential Manager: Go to
User Accounts
and selectCredential Manager
. - Manage Windows Credentials: Click on the “Windows Credentials” tab.
- Delete Unnecessary Git Credentials: Remove any Git-related credentials that are no longer needed.
- Navigate to Credential Manager: Go to
Step 2: Install Git and GitHub Desktop
With the old installations out of the way, you can now proceed with installing the latest versions of Git and GitHub Desktop:
- Download Git: Install version 2.47.0 (64-bit) or higher from the official Git website.
- Download GitHub Desktop: Download the GitHub Desktop Setup (x64) from the official GitHub Desktop website.
- Follow the Prompts: Go through the installation prompts for both applications until they are fully installed.
Step 3: Launch GitHub Desktop
Once everything is installed, open GitHub Desktop:
- Launch GitHub Desktop: Find it in your applications and open it.
Step 4: Clone a Repository
Now it’s time to clone a repository from GitHub:
- File Menu: In GitHub Desktop, go to
File
and selectClone Repository
. - Copy Repository Link: Navigate to your GitHub account in a browser, find the repository you want to clone, and copy the HTTPS link.
- Follow the Prompts: Paste the link into GitHub Desktop and follow the prompts to complete the cloning process.
Step 5: Open the Repository in Visual Studio Code
After successfully cloning the repository, you can open it in Visual Studio Code:
- Open in VS Code: Click the option to “Open in Visual Studio Code” in GitHub Desktop.
Step 6: Make a Simple Change
Now it’s time to make a small change to verify that everything is working properly:
- Edit the Code: Open any file in the repository and make a simple change, like adding a comment.
Step 7: Commit and Push Your Changes
Once you’ve made your change, it’s time to save it back to the repository:
- Click the Source Control Icon: In Visual Studio Code, find and click the Source Control icon in the sidebar.
- Add a Commit Message: Enter a brief message describing your change.
- Commit the Change: Click the “Commit” button to save your changes locally.
- Push to GitHub: Finally, click the “Push” button to send your changes to the remote repository on GitHub.
Conclusion
By following these steps, you’ve successfully set up Git and GitHub with Visual Studio Code, cloned a repository, made a change, and pushed it back to GitHub. With this workflow in place, you’re ready to take on more complex projects and collaborate effectively! Happy coding!