Visual Studio Code To Github



Setting up Visual Studio Code. Getting up and running with Visual Studio Code is quick and easy. It is a small download so you can install in a matter of minutes and give VS Code a try. VS Code is a free code editor, which runs on the macOS, Linux, and Windows operating systems. Follow the platform-specific guides below: macOS. Using GitHub with Visual Studio Code lets you share your source code and collaborate with others. GitHub integration is provided through the GitHub Pull Requests and Issues extension. Install the GitHub Pull Requests and Issues extension. To get started with the GitHub in VS Code, you'll need to create an account and install the GitHub Pull Requests and Issues extension. In this topic, we'll demonstrate how. Connect to remote and virtual machines with Visual Studio Code via SSH. Work in WSL: Run Visual Studio Code in Windows Subsystem for Linux. Develop in Containers: Run Visual Studio Code in a Docker Container. GitHub Codespaces: Connect to a codespace with Visual Studio Code. Visual Studio Code. Visual Studio Code is a distribution of the Code - OSS repository with Microsoft specific customizations released under a traditional Microsoft product license. Visual Studio Code combines the simplicity of a code editor with what developers need for their core edit-build-debug cycle. It provides comprehensive code editing, navigation, and understanding support along with lightweight. Sign in to GitHub by using Visual Studio Code. Use Visual Studio Code to search GitHub for repos. Clone a repo from Visual Studio Code. Publish a local project to GitHub by using Visual Studio Code. View a timeline of activity on a GitHub repo.

By: Matt Wollner

Our Branch-Based GitHub Workflow

Now that Microsoft has acquired GitHub, our team here at Key2 Consulting is starting the transition from Team Foundation Server (TFS) to GitHub for our database source control. If you are accustomed to working with TFS, the transition to GitHub can be confusing.

In this blog post, we share a basic workflow we have adopted to start using GitHub as our project source control. Our GitHub workflow takes advantage of Visual Studio Code (VS Code). We will cover (in this post) the basics of how to get a local copy, push code changes to the development branch, and then pull those changes into the master branch.

Master Branch and Develop Branch

There are often many code changes in between releases when working on a project. Some of these changes are ready for deployment to a production environment, while some are under development and testing.

Push Visual Studio Code To Github

At Key2 Consulting, we use a branch-based workflow to help pick the changes that are ready for deployment. Our environment has two main branches: master (or main) branch and develop branch.

Hotfix branches are created to move code from the develop branch to the master branch, and are then deleted after master has been updated.

  • Master Branch – Once code is added to the master branch it is ready for deployment. The master branch will represent production-ready code.
  • Develop Branch – All ongoing development should be done in the develop branch.
Connecting visual studio code to github


How To Add Visual Studio Code To Github

Downloading a Branch (Clone)

Let’s start by setting up our working environment. To do so, we will “clone” the develop branch. This will download the latest code in the development branch into our local PC.

In my personal working environment, I like to have a copy of both the develop and master branches. I create a root folder for the projects and a folder for each branch underneath.

Visual Studio Code Commit To Github

CodeVisual Studio Code To Github
  1. In Files Explorer, create a folder for your working develop environment.
  2. Open VS Code and open the new folder. File –> Open Folder
  3. Jump over to your GitHub website. Get the Clone HTML. Click the Clone or Download button and copy the URL.

  4. Clone the repository.
    • Back in VS Code, go to the Terminal command prompt and type in the command: git clone https://githuburl…
    • – In this example, I am pulling the https URL. You may set your URL to begin with git:// or use SSH transfer protocol user@server:path/to/repo.git.


      OR

    • Open the Command Palette… (Ctrl+Shift+P)
    • – Git: Clone


      – Paste in URL


  5. You should now see the repository in your local folder.
  6. In VS Code, on the bottom left of the window you will see what branch you are currently working with. Mine currently says “master”. I need to change it to develop. If you click on master you will see the git command prompt drop down, but sometimes you may not see all the branches that are in the GitHub project.

Studio


To refresh the ref list you may need to run the fetch command.

  1. In the Terminal command prompt (Ctrl+`), run the command:
  2. git fetch

  3. Now if you click on the branch name in the bottom left, you should see all your branches in the drop down. Select the develop branch.

Working With Your Local Copy

While working on your local copy of the repository, you should frequently get the latest version from GitHub. In Git, this is done with the “pull” command. If you are editing objects, you need to make sure you have the latest version before you begin.

Under the Source Control tab, click the “…” -> Pull
Or
Terminal command prompt
Git pull


Committing to the Remote Develop Branch

After you have made some code changes and they have all tested out, you will want to deploy the changes to the remote develop branch. From VS Code you will use the Stage, Commit and Push commands. All files that have been altered will show up in the Source Control tab.

Visual Studio Code To Github

  1. Select the files you wish to deploy from your local environment to the remote develop branch.
  2. “Stage”.
  3. a. You can stage files by selecting the files you wish to stage. Right click Stage Changes.

    b. Staging allows you to gather the files that you wish to commit.

  4. “Commit”.
  5. a. Add a message. Click the ellipsis and select Commit Staged.

    b. The commit will save your changes to your local repository. This can be a little confusing. You can no longer see the updated files, but they have NOT been pushed to the remote develop branch yet.

  6. “Push”.
  7. a. After the files have been committed to your local repository you will need to push them to the remote repository (aka GitHub server).


    Your code changes are now on the remote develop branch. If you browse to your GitHub server, you will see a message next to each item for when it was last committed, along with the message you added during the commit. Any other developer who runs a pull command will download your changes to their local environment.

    Deploying to Production

    We now want to deploy our code changes to production (our remote master repository). Most of the time we will not want to deploy all the code in the develop branch. We will create a new local branch from the master branch and copy over all the code changes we wish to deploy. We will then pull those changes to the remote master branch.

    1. Create a new branch from the master branch.