GitHub-VSCode Beginners Guide for Code Merge (The strict GUI-method)
Image Credit - Adobe Express

GitHub-VSCode Beginners Guide for Code Merge (The strict GUI-method)

I was learning Python and learned to use GitHub with VS Code along the way. Would like to share the same with all the beginners like me.

In this article, you would learn how to merge your code created in VS Code with your GitHub repository. Let's begin!

First of all, let's split the topic in 5 different sections for better understanding.

  1. Prerequisites (what you need to know before you start)
  2. Clone the code.
  3. Creating a branch to create/update the code.
  4. Commit the Code.
  5. Merge the Code.


Prerequisites

  • Install VS Code.
  • You should have GitHub account, repository and a basic idea of how it works.
  • Install GIT and for the first-time setup of "user.name" and "user.email".

To setup "user.name" and "user.email" for the GIT, just open the cmd/terminal depending upon which OS you are on, and type the below two commands, replacing it your name and email address.

git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"        


Clone the Code

  • Login to the GitHub and open the repository you wish to use.
  • Copy the HTTPS clone URL.

clone

  • Open VS Code, open Command Palette and search for GIT:Clone.
  • Upon asked, paste the HTTPS clone URL and click enter. You will be prompted to authorize the GitHub access to VS Code, please do so and your code will be cloned locally on your computer.
  • Open the code project folder in the VS Code.
  • Open VS Code Source Control (on left pane) and click Initialize Repository.


Creating a branch to create/update the Code

Even though it's not mandatory to create a branch and you can directly update the code in main branch, however it's a best practice to do so.

  • Open VS Code, navigate to View > Command Palette and search for "GIT:Create" Branch.

create branch
branch-name

  • Name the branch and click enter. Notice that the branch name will update to the one you created on the left bottom corner of the VS Code. This is where you identify the branch you are working in.
  • Create a new or make the changes to your existing code. Save the code.


Commit the Code

No alt text provided for this image

  • Navigate to the Source Control where you would be able to see that there are few changes in your project. These changes will just under Staged Changes as they are not yet committed.
  • Hover over Staged Changes and click on the + icon next to it.
  • Type a meaningful comment that defining what changes have you done in the project and click "Commit". What this does is it creates a pull request.

Note: Pull request is a request that is made to the GitHub repository to merge the code with the main branch.


Merge the Code

  • Open GitHub.com and navigate to your repository.
  • Open the Pull requests tab and select the pull request that we just created.

pull request

  • Click on "Merge pull request" button.
  • Update the relevant description and click on "Confirm merge" and you have successfully merged your code.

Congratulations on merging your first code in GitHub using VS Code! I hope this helped!

Tags: #github #vscode #newdevelopers

To view or add a comment, sign in

Others also viewed

Explore content categories