Git and GitHub: A Guide for VS Code Users

Cloud Engineer and DevOps enthusiast, just talking about AWS, Docker, Linux, Kubernetes, Python, and automation.
Search for a command to run...

Cloud Engineer and DevOps enthusiast, just talking about AWS, Docker, Linux, Kubernetes, Python, and automation.
No comments yet. Be the first to comment.
In today's rapidly evolving technological landscape, the demand for scalable and automated infrastructure deployment has become crucial. This is where Terraform, an open-source infrastructure as code (IaC) tool, comes into play. With Terraform, you c...
Running your own home lab used to mean expensive hardware, complex networking, and hours of manual configuration. This project changes that. With a single Raspberry Pi, Docker Compose, and a few hundr

Welcome to an advanced hybrid directory demo where we'll guide you through setting up a hybrid environment, connecting to simulated on-premises infrastructure, creating a managed Microsoft AD within AWS, establishing a two-way forest trust, and integ...

Hello DevOps Community! Today marks the completion of the #90DaysOfDevOps Challenge, and it's a moment to reflect on the journey we've undertaken together. Throughout this period, I've engaged with various technologies, refining my skills in the DevO...

In a modern cloud infrastructure setup, creating a robust and scalable 2-tier architecture is essential. Such an architecture helps meet the demands of your applications while ensuring repeatability, reliability, and security. In this article, we'll ...

Welcome to Part 4 of my series on building a comprehensive CI/CD pipeline in AWS. In this article, I will explore AWS CodePipeline, a powerful service for building and deploying applications in a continuous integration and continuous delivery (CI/CD)...

Git is a version control system that enables you to manage the changes made to your code, track the history of those changes, and collaborate with others on projects.
GitHub is a web-based platform that provides Git hosting, as well as additional features for project management, bug tracking, and more.
In this guide, I'll walk you through the steps for using Git and GitHub with Visual Studio Code (VS Code), a popular code editor.
To use Git, you'll need to have it installed on your computer. If you don't already have it installed, you can download it from the official Git website. Once you've installed Git, you'll need to open a terminal window and enter the following command to check if it's installed properly:
git --version
The next step is to install the Git extension for Visual Studio Code. You can do this by opening the Extensions panel (View > Extensions), searching for "Git", and clicking the "Install" button next to the Git extension.
To clone a GitHub repository, you'll need to have a GitHub account and have the repository URL. If you don't already have a repository, you can create a new one on GitHub.
Once you have the repository URL, you can clone it to your local machine by opening a terminal window in VS Code (View > Terminal), and entering the following command:
git clone https://github.com/user/repo.git
Replace https://github.com/user/repo.git with the URL of the repository you want to clone.
Now that you have the repository cloned to your local machine, you can start making changes to the code. Open the repository in VS Code, and make the changes you want. Once you're done, you can use the terminal window to the stage and commit the changes.
To stage changes in the terminal window, use the following command:
git add <file name>
To commit the changes in the terminal window, use the following command:
git commit -m "commit message"
To push the changes you made to the GitHub repository, you'll need to enter the following commands in the terminal window:
git push origin main
Replace origin with the name of the remote repository, and main with the name of the branch, you want to push to.
Here is a summary of some common Git commands that you can use with the Git extension for Visual Studio Code or in the terminal:
git clone: This command is used to clone a remote repository to your local machine. The syntax is git clone <repository URL>.
git init: This command is used to initialize a new Git repository in your current directory.
git status: This command is used to view the current status of your repository, including the files that have been modified, staged, and committed.
git add: This command is used to stage changes to a file. The syntax is git add <file name>.
git commit: This command is used to commit the staged changes to the local repository. The syntax is git commit -m "commit message".
git push: This command is used to push the committed changes to a remote repository. The syntax is git push <remote name> <branch name>.
git pull: This command is used to retrieve changes from a remote repository and merge them into the local repository. The syntax is git pull <remote name> <branch name>.
git branch: This command is used to manage branches in your Git repository. You can use the git branch command to list the branches in your repository, create a new branch, or switch between branches.
These are just a few of the many Git commands available. By using Git and the Git extension for Visual Studio Code, you can manage your code repositories with ease and collaborate with others on your projects.
Visual Studio Code has a built-in source control plugin that integrates with Git, providing an easy way to manage changes to your code. Here are the steps to use the source control plugin in Visual Studio Code:
Open the Source Control panel by clicking on the Source Control icon in the Activity Bar on the left side of the editor or by going to View > Source Control.
In the Source Control panel, you'll see a list of the changes you've made to your code. You can stage changes by clicking the "+" icon next to each change, or you can stage all changes by clicking the "+" icon at the top of the panel.
Once you've staged the changes, you can enter a commit message in the text box at the top of the panel and click the checkmark icon to commit the changes.
To push your changes to GitHub, you can click the ... icon at the top of the panel and select "Push".
You can also view the history of your changes by clicking the history icon in the Source Control panel. This will show you a list of all the commits you've made, including the date, author, and message for each commit.
The source control plugin in Visual Studio Code provides a convenient way to manage your Git repositories and keep track of changes to your code. By using the plugin, you can focus on writing code and leave the source control management to Visual Studio Code.
In conclusion, Git and GitHub are powerful tools for managing and collaborating on code projects. By following the steps outlined in this guide, you can start using Git and GitHub with Visual Studio Code and take your coding projects to the next level.