Visual Studio For Mac Git Setup

Active1 month ago

When using git at the command line, I am wondering if it is possible to use Visual Studio Code as the default editor, i.e. when creating commit comments, and looking at a diff of a file from the command line.

I understand that it won't be possible to use it for doing merges (at least at the minute) but does anyone know if it is possible to use it for looking at diff's, and if so, what command line options would be required in the .gitconfig file to make this happen?

Connect to Git repository with SSH using Visual Studio 2017. I'm using VS2017 Com. For Mac and having the same issues. Tried Mac-ish versions of the below, nothing. Removed 'git for windows' on Visual Studio Installer and delete git on control panel; Installed two of them. 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. Extension for Visual Studio - An extension for Team Explorer to provide source control integration for Git. Enables integration with local Git repositories and provides tools to work with remote repositories. In Visual Studio for mac I connected and checked out a project from git repository. I call context menu by clicking on the project and see this.

UPDATE 1:

I have tried an approach similar to what I have done for Notepad++ in the past, i.e.

And used:

But this results in an error message:

Code opens up correctly, with the expected content, but it isn't waiting on the response, i.e. clicking save and closing the window to return to prompt.

UPDATE 2:

I have just heard back from one of the developers working on VSCode. Looks like this functionality currently isn't supported :-(

Visual Studio

If you are interested in seeing this feature get added, you might want to think about adding your votes here:

UPDATE 3:

Studio

I have been reliably informed that this feature has been picked up by the VSCode team, so I am looking forward to a future release that will include it.

UPDATE 4:

Thanks to @f-boucheros comment below, I have been able to get VS Code working as the default editor for commit comments, rebase, etc. I would still like to see if it is possible to use it as the diff tool as well.

UPDATE 5:

As per the accepted answer for the question, this is now possible using the V1.0 release of code.

Community
Gary Ewan ParkGary Ewan Park
8,5054 gold badges20 silver badges46 bronze badges

12 Answers

In the most recent release (v1.0, released in March 2016), you are now able to use VS Code as the default git commit/diff tool. Quoted from the documentations:

  1. Make sure you can run code --help from the command line and you get help.

    • if you do not see help, please follow these steps:

      • Mac: Select Shell Command: Install 'Code' command in path from the Command Palette.

        • Command Palette is what pops up when you press shift + + P while inside VS Code. (shift + ctrl + P in Windows)
      • Windows: Make sure you selected Add to PATH during the installation.
      • Linux: Make sure you installed Code via our new .deb or .rpm packages.
  2. From the command line, run git config --global core.editor 'code --wait'

Now you can run git config --global -e and use VS Code as editor for configuring Git. Add the following to enable support for using VS Code as diff tool:

This leverages the new --diff option you can pass to VS Code to compare two files side by side.

To summarize, here are some examples of where you can use Git with VS Code:

  • git rebase HEAD~3 -i allows to interactive rebase using VS Code
  • git commit allows to use VS Code for the commit message
  • git add -p followed by e for interactive add
  • git difftool <commit>^ <commit> allows to use VS Code as diff editor for changes
leerssej
6,2112 gold badges26 silver badges42 bronze badges
rexcfnghkrexcfnghk
7,8551 gold badge23 silver badges48 bronze badges

For what I understand, VSCode is not in AppData anymore.

So Set the default git editor by executing that command in a command prompt window:

The parameter -w, --wait is to wait for window to be closed before returning. Visual Studio Code is base on Atom Editor. if you also have atom installed execute the command atom --help. You will see the last argument in the help is wait.

Next time you do a git rebase -i HEAD~3 it will popup Visual Studio Code. Once VSCode is close then Git will take back the lead.

Note: My current version of VSCode is 0.9.2

I hope that help.

Frank BoucherFrank Boucher

You need to use command:

Make sure you can start your editor from Git Bash

If you want to use Code.exe with short path, you can do this by adding the following line to your .bash_profile:

And now, you can call it using only vscode command(or whatever you named it)

Some additional info:

Setup will add Visual Studio Code to your %PATH%, so from the console you can type 'code' to open VS Code on that folder. You will need to restart your console after the installation for the change to the %PATH% environmental variable to take effect.

IluxaKukIluxaKuk

I opened up my .gitconfig and amended it with:

That did it for me (I'm on Windows 8).

However, I noticed that after I tried an arbitrary git commit that in my Git Bash console I see the following message:

Unsure of what the ramifications of this might be.

miqhmiqh
2,8532 gold badges21 silver badges31 bronze badges

Another useful option is to set EDITOR environment variable. This environment variable is used by many utilities to know what editor to use. Git also uses it if no core.editor is set.

You can set it for current session using:

This way not only git, but many other applications will use VS Code as editor.

To make this change permanent, add this to ~/.profile for example. See this question for more options.

Ruslan StelmachenkoRuslan Stelmachenko

GitPad sets your current text editor as the default editor for Git.

My default editor for .txt files in Windows 10 is Visual Studio Code and running GitPad once made it the default editor for Git. I haven't experienced the problems mentioned in the question (Git waits until VS Code window is closed in my case).

(The link for the .exe file didn't work for me, you may need to compile the source yourself.)

Şafak GürŞafak Gür
3,6623 gold badges41 silver badges78 bronze badges

Good news! At the time of writing, this feature has already been implemented in the 0.10.12-insiders release and carried out through 0.10.14-insiders. Hence we are going to have it in the upcoming version 1.0 Release of VS Code.

Implementation Ref: Implement -w/--wait command line arg

Wasif HossainWasif Hossain
3,3241 gold badge12 silver badges17 bronze badges
MohammedMohammed
5742 gold badges8 silver badges26 bronze badges

Just want to add these back slashes to previous answers, I am on Windows 10 CMD, and it doesn't work without back slashes before the spaces.

Victor MaVictor Ma

Im not sure you can do this, however you can try these additions in your gitconfig file.

Try to replace the kdiff3 from these values to point to visual studio code executable.

[merge] tool = kdiff3 [mergetool 'kdiff3'] path = C:/Program Files/KDiff3/kdiff3.exe keepBackup = false trustExitCode = false

SJManSJMan
8872 gold badges10 silver badges25 bronze badges

Visual Studio For Mac Git Setup Ssh

I set up Visual Studio Code as a default to open .txt file. And next I did use simple command: git config --global core.editor 'C:UsersUserNameAppDataLocalCodeapp-0.7.10Code.exe'. And everything works pretty well.

ZiduZidu

on windows 10 using the 64bit insiders edition the command should be:

git config --global core.editor 'C:Program FilesMicrosoft VS Code Insidersbincode-insiders.cmd'

you can also rename the 'code-insiders.cmd' to 'code.cmd' in the 'Program Files' directory, in this way you can now use the command 'code .' to start editing the files on the . directory

LuisCarlos RodriguezLuisCarlos Rodriguez

Not the answer you're looking for? Browse other questions tagged gitvisual-studio-code or ask your own question.

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.

Cross platform

VS Code is a free code editor which runs on the macOS, Linux and Windows operating systems.

Follow the platform specific guides below:

Visual Studio Git Integration

VS Code is lightweight and should run on most available hardware and platform versions. You can review the System Requirements to check if your computer configuration is supported.

Update cadence

VS Code releases a new version each month with new features and important bug fixes. Most platforms support auto updating and you will be prompted to install the new release when it becomes available. You can also manually check for updates by running Help > Check for Updates.

Note: You can disable auto-update if you prefer to update VS Code on your own schedule.

Insiders nightly build

If you'd like to try our nightly builds to see new features early or verify bug fixes, you can install our Insiders build. The Insiders build installs side-by-side with the monthly Stable build and you can freely work with either on the same machine. The Insiders build is the same one the VS Code development team uses on a daily basis and we really appreciate people trying out new features and providing feedback.

Additional components

VS Code is an editor, first and foremost, and prides itself on a small footprint. Unlike traditional IDEs which tend to include everything but the kitchen sink, you can tune your installation to the development technologies you care about. Be sure to read the Additional Components topic after reading the platform guides to learn about customizing your VS Code installation.

Extensions

VS Code extensions let third parties add support for additional:

  • Languages - C++, C#, Go, Java, Python
  • Tools - ESLint, JSHint , PowerShell
  • Debuggers - Chrome, PHP XDebug.
  • Keymaps - Vim, Sublime Text, IntelliJ, Emacs, Atom, Visual Studio, Eclipse

Visual Studio For Mac Tutorial

Extensions integrate into VS Code's UI, commands, and task running systems so you'll find it easy to work with different technologies through VS Code's shared interface. Check out the VS Code extension Marketplace to see what's available.

Next steps

Once you have installed and set up VS Code, these topics will help you learn more about VS Code:

  • Additional Components - Learn how to install Git, Node.js, TypeScript and tools like Yeoman.
  • User Interface - A quick orientation to VS Code.
  • Basic Editing - Learn about the powerful VS Code editor.
  • Code Navigation - Move quickly through your source code.
  • Debugging - Debug your source code directly in the VS Code editor.
  • Proxy Server Support - Configure your proxy settings.

If you'd like to get something running quickly, try the Node.js tutorial walkthrough which will have you debugging a Node.js web application with VS Code in minutes.

Common questions

What are the system requirements for VS Code?

We have a list of System Requirements.

Visual Studio Git Repository

How big is VS Code?

VS Code is a small download (< 100 MB) and has a disk footprint of less than 200 MB, so you can quickly install VS Code and try it out.

How do I create and run a new project?

VS Code doesn't include a traditional File > New Project dialog or pre-installed project templates. You'll need to add additional components and scaffolders depending on your development interests. With scaffolding tools like Yeoman and the multitude of modules available through the npm package manager, you're sure to find appropriate templates and tools to create your projects.

How do I know which version I'm running?

On Linux and Windows, choose Help > About. On macOS, use Code > About Visual Studio Code.

Why is VS Code saying my installation is Unsupported?

VS Code has detected that some installation files have been modified, perhaps by an extension. Reinstalling VS Code will replace the affected files. See our FAQ topic for more details.