随着Visual Studio 2015的发布,git集成更加紧密。
然而,似乎缺少的功能是通过SSH使用git。有多种2013插件可允许此功能(如GitExtensions),但我在2015中找不到这样的插件。
GitHub插件似乎只能用于GitHub而非一般的git仓库。
我不是要求评价哪个更好,只希望能看到一些示例或文章,以查看是否有人已经使Git+SSH在Visual Studio 2015上工作。
随着Visual Studio 2015的发布,git集成更加紧密。
然而,似乎缺少的功能是通过SSH使用git。有多种2013插件可允许此功能(如GitExtensions),但我在2015中找不到这样的插件。
GitHub插件似乎只能用于GitHub而非一般的git仓库。
我不是要求评价哪个更好,只希望能看到一些示例或文章,以查看是否有人已经使Git+SSH在Visual Studio 2015上工作。
不支持SSH进行Git远程操作,这在Visual Studio 2015(RTM)中是不可用的。即使使用GitHub插件连接GitHub仓库时(目前使用与Team Explorer相同的Git仓库连接机制),也是如此。
这是令人遗憾的,但有一些原因说明为什么还未提供此功能:简短的答复是,在我们看来,提供SSH的质量差或不安全比不提供SSH更糟糕,我们希望确保提供的任何SSH实现都具有高质量。
也就是说,我们正在努力,并取得了进展。微软将开始在Windows中包含OpenSSH(并且是该项目的赞助商)。但是我无法预测何时会提供支持。
GitHub插件是开源的,因此可能可以使用不同的连接机制,并开始在Team Explorer之前支持SSH。
Do the following:
cd <libssh2 root dir> (e.g. wherever you extracted the source to)
mkdir build && cd build
cmake -DCRYPTO_BACKEND=WinCNG -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
Open the resulting libssh2.sln in the build directory
构建libgit2
Do the following:
cd <libgit2 source dir> (e.g. this is wherever you extracted the libgit2 source you got from VS2015's extensions directory, see BPas' link for details)
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSTDCALL=ON -DSTATIC_CRT=OFF -DUSE_SSH=OFF -DLIBSSH2_FOUND=TRUE -DLIBSSH2_INCLUDE_DIRS=<libssh2 root dir>/include -DLIBSSH2_LIBRARIES=<libssh2 root dir>/build/src/Release/libssh2.lib ..
Open the resulting libgit2.sln in the build directory
Optional: Patch src/transports/ssh.c to support SSH RSA key authentication, in function request_creds (around line 444):
if (!t->owner->cred_acquire_cb) {
no_callback = 1;
} else {
with:
if (!t->owner->cred_acquire_cb) {
if (user) {
const char *val = NULL;
val = getenv("USERPROFILE");
if (val)
{
char *szprivfilename = malloc(strlen(val) + 128);
char *szpubfilename = malloc(strlen(val) + 128);
strcpy(szprivfilename, val);
strcat(szprivfilename, "/.ssh/id_rsa");
strcpy(szpubfilename, val);
strcat(szpubfilename, "/.ssh/id_rsa.pub");
git_cred_ssh_key_new(&cred, user, szpubfilename, szprivfilename, "");
free(szprivfilename);
free(szpubfilename);
}
if (!cred) {
giterr_set(GITERR_SSH, "git_cred_ssh_key_new failed to initialize SSH credentials");
return -1;
}
}
else
{
no_callback = 1;
}
} else {
Note: this patch was grabbed from one the comments in randomswdev's post, seems to work fine from my limited testing.
符合BPas标准:对于Visual Studio 2015,可以构建启用SSH的版本。此外,我有一个公钥/私钥认证支持的补丁:
http://randomswdev.blogspot.it/2015/07/adding-ssh-support-to-visual-studio.html
这里曾经有一些关于使用git bash将你的git添加到Visual Studio的无意义内容。 尽管添加是可行的,但创建提交也是一个选项,但同步它们仍然需要使用git bash。 所以这样做有点无用。