Visual Studio Code - All the Git Features!!!

Visual Studio Code supports Git... like a BOSS!!!

VS Code gets Git!

 

Let's look at the features!

Git version control

Commit, diff, pull and push

Code has Git Version Control support built into the editor

Embrace modern workflows with the power and flexibility of Git. See changed files, diffs, and make commits right from within the editor. Connect with the entire Git universe by pulling and pushing code to any remote — GitHub, Azure Web Apps, Visual Studio Team Services, and more.

Scoped Git Services

You can open a sub-directory of a Git repository in VS Code. VS Code's Git services show all the changes within the repository, but file changes outside of the scoped directory are shaded and have a tool tip indicating the file is located outside the current workspace.

Git Status Bar Actions

There is a Synchronize action in the Status Bar, next to the branch indicator, when the current checked out branch has an upstream branch configured.

git status bar sync

If there is no upstream branch configured and the Git repository has remotes set up, a new Publish action is enabled. This will let you publish the current branch to remote.

git status bar publish

Commit

Staging and unstaging can be done via contextual actions in the files or by drag-and-drop.

You can type a commit message above the changes and press Ctrl+Enter (Mac: ⌘+Enter) to commit them. If there are any staged changes, only those will be committed, otherwise all changes will be committed.

Git - Undo Last Commit

There is an Undo Last Commit action which will let you undo your previous commit, keeping the changes in the working folder.

Branches and Tags

You can create and checkout branches directly within VS code through the Command Palette. Press Ctrl+P, type git and then press Space. You should see the following:

Git commands

If you type checkout and press Space again, you will see a dropdown containing all of the branches or tags in the current repository.

Git checkout

The git branch command lets you quickly create a new branch.  Just provide the name of your new branch and VS Code will create the branch and switch to it.

Merge Conflicts

Git merge

Merge conflicts are recognized by VS Code; we try to provide useful coloring markers in the gutter to the right of the code line numbers, to help you with resolving them. The green bar markers specify lines that were added, the red arrow markers specify lines that were removed, and the blue bar markers specify lines that have been altered. Once resolved, stage the conflicting file so you can commit. Click the Git icon in the sidebar to display all the changes.

Viewing Diffs

Our Git tooling supports viewing of Diffs within VS Code. Click the file in the Git view to display a side-by-side view. This allows you to compare your current file with a previous version of it:

A File Diff in VS Code

Remotes

Given that your repository is connected to some remote and that your checked out branch has an upstream link to a branch in that remote, VS Code offers you useful actions to push, pull and sync that branch (the latter will run a pull command followed by a push command). You can find these actions in the ... menu.

Credential prompt

To avoid the Git action being blocked by an authentication prompt, when Git requires credentials you will see a pop-up, prompting you to enter the required credentials.

Credential prompt

Tip: If you don’t want to always enter your credentials, consider using a credential helper.

Multi-line commit

Commit messages in VS Code supported support multiple lines of text in your commit message. (Type Ctrl+Enter to finish the commit message, or Enter to add a new line to the message.)

Multiline commit message

Multiple file selection

Multiple selection is available in the Git view, meaning you can stage/unstage or commit multiple files at the same time.

Select multiple files

Auto fetch control

There is an action to enable/disable Git auto fetch in the dropdown menu of the Git view. This is handy if you don’t have a credential helper and don’t want to get prompted for authentication all the time.

Engineering - GitHub

The VS Code GitHub repository supports continued integration for branches and pull requests:

During this first iteration of VS Code being open source, we tuned and documented more of our development workflows:

Electron is updated to version 0.34.5.  This includes a bug fix for the issue on Linux where the editor font was showing blurry on certain high DPI displays.

QUICK PICK AND INPUT - GitHub Octicons

You can validate user input, get called when an item is focused in Quick Pick, and Quick Pick now has room for additional details. Also Quick Pick now supports GitHub Octicons like the Status Bar.

 

 

More info on these features:

 

This blog post (that you're reading now) is reason #6 as to why you should teach Java out of Visual Studio Code:

Why should I teach Java out of Visual Studio Code instead of out of Eclipse or Netbeans?

 

Have a great bye! Or maybe just have a good one.

- Ninja Ed