开发者

How can I use an already-loaded Visual Studio 2010 instance as my git commit editor?

I'm working in Visual Studio 2010, but using Git from the command line (for now, at least). When I do a git commit, it opens some editor I don't know.

I've been able to set Notepad as the commit message editor like this:

  • git config --global core.editor notepad.exe

I was able to get it to use Visual Studio 2010 like this:

  • git config --global core.editor "'C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/devenv.exe'"

But what I want to do is set git to use an already-running instance of Visual Studio 2010, if possible.

The /Edit command line switch for devenv.exe is supposed to be able to do this, but what syntax should I use in the git config开发者_开发百科 line?

EDIT: It appears that this works...but not entirely:

git config --global core.editor "'C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/devenv.exe' -edit"

I say "not entirely" because, while it does indeed open the commit message file in the running instance of VS 2010, git also immediately gives me the "There was a problem with the editor" message. And saving the file doesn't do anything. It seems as if git expects the commit message editor to open (rather than already be open), and to close when the message is complete.


I would recommend using Notepad2 or Notepad++. They are developer oriented editors but still quite simple and easy to use. They will handle the line endings just fine (which is the problem with mixing notepad.exe with git). Notepad2 is a better choice than Notepad++ in this case IMO.


I'm guessing you want VS for commit edits because you are doing your source code editing in there too, right?

If you are starting down the road to integration like this, you probably just want to install GitExtensions and be done with it. That will integrate Git into your VisualStudio environemnt nicely for you.

This will make it much easier for you. The command line is really best used by folks familiar with unix commands. If you are intimidated by things like the vi editor, you probably should avoid it.

If you really want to stick with the command line, I'd suggest using something lighter than VisualStudio for simple commit edits. Notepad will probably work fine. Commit edits are just simple text. You don't need VisualStudio for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜