1
0
Форкнуть 0

Merge pull request #291 from Microsoft/markdown-help

Creating /docs section for better help and information browsing
This commit is contained in:
J Wyman 2016-09-22 12:52:58 -04:00 коммит произвёл GitHub
Родитель e9f9587f21 b5fbfe6474
Коммит 8d0372ac6f
24 изменённых файлов: 712 добавлений и 299 удалений

30
Assets/help.css Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -91,7 +91,6 @@
</Page>
</ItemGroup>
<Import Project="..\Cli-Shared\Cli-Shared.projitems" Label="Shared" />
<Import Project="..\CommonShared\CommonShared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>

Просмотреть файл

@ -1,8 +1,10 @@
using System;
using Microsoft.Alm.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Alm.Authentication;
namespace Microsoft.Alm.Cli
{
@ -192,11 +194,34 @@ namespace Microsoft.Alm.Cli
private static void PrintHelpMessage()
{
const string HelpFileName = "git-askpass.html";
Console.Out.WriteLine("usage: git askpass '<user_prompt_text>'");
Console.Out.WriteLine();
PrintConfigurationHelp();
Console.Out.WriteLine();
List<Git.GitInstallation> installations;
if (Git.Where.FindGitInstallations(out installations))
{
foreach (var installation in installations)
{
if (Directory.Exists(installation.Doc))
{
string doc = Path.Combine(installation.Doc, HelpFileName);
// if the help file exists, send it to the operating system to display to the user
if (File.Exists(doc))
{
Git.Trace.WriteLine($"opening help documentation '{doc}'.");
Process.Start(doc);
return;
}
}
}
}
Console.Error.WriteLine("Unable to open help documentation.");
Git.Trace.WriteLine("failed to open help documentation.");
}
}
}

Просмотреть файл

@ -72,7 +72,6 @@
</ProjectReference>
</ItemGroup>
<Import Project="..\Cli-Shared\Cli-Shared.projitems" Label="Shared" />
<Import Project="..\CommonShared\CommonShared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
@ -93,6 +92,8 @@ COPY /V /Y "%25src%25git-credential-manager.exe" /B "%25dst%25git-credential-man
COPY /V /Y "%25src%25install.cmd" /A "%25dst%25install.cmd" /A
COPY /V /Y "%25src%25README.md" /A "%25dst%25README.md" /A
COPY /V /Y "%25src%25LICENSE.TXT" /A "%25dst%25LICENSE.TXT" /A
"$(ProjectDir)build-docs.cmd"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

Просмотреть файл

@ -41,7 +41,7 @@ namespace Microsoft.Alm.Cli
internal const string FailFace = "U_U";
internal const string TadaFace = "^_^";
//private static readonly Version NetFxMinVersion = new Version(4, 5, 1);
private static readonly IReadOnlyList<string> Files = new List<string>
private static readonly IReadOnlyList<string> FileList = new string[]
{
"Microsoft.Alm.Authentication.dll",
"Microsoft.Alm.Git.dll",
@ -51,6 +51,11 @@ namespace Microsoft.Alm.Cli
"git-credential-manager.exe",
"git-askpass.exe",
};
private static readonly IReadOnlyList<string> DocsList = new string[]
{
"git-askpass.html",
"git-credential-manager.html",
};
public Installer()
{
@ -256,15 +261,29 @@ namespace Microsoft.Alm.Cli
Console.Out.WriteLine();
Console.Out.WriteLine($"Deploying from '{Program.Location}' to '{installation.Path}'.");
if (CopyFiles(Program.Location, installation.Libexec, out copiedFiles))
if (CopyFiles(Program.Location, installation.Libexec, FileList, out copiedFiles))
{
int copiedCount = copiedFiles.Count;
foreach (var file in copiedFiles)
{
Console.Out.WriteLine($" {file}");
}
// copy help documents
if (Directory.Exists(installation.Doc)
&& CopyFiles(Program.Location, installation.Doc, DocsList, out copiedFiles))
{
copiedCount += copiedFiles.Count;
foreach (var file in copiedFiles)
{
Console.Out.WriteLine($" {file}");
}
}
Program.LogEvent($"Deployment to '{installation.Path}' succeeded.", EventLogEntryType.Information);
Console.Out.WriteLine($" {copiedFiles.Count} file(s) copied");
Console.Out.WriteLine($" {copiedCount} file(s) copied");
}
else if (_isForced)
{
@ -290,15 +309,27 @@ namespace Microsoft.Alm.Cli
Directory.CreateDirectory(UserBinPath);
}
if (CopyFiles(Program.Location, UserBinPath, out copiedFiles))
if (CopyFiles(Program.Location, UserBinPath, FileList, out copiedFiles))
{
int copiedCount = copiedFiles.Count;
foreach (var file in copiedFiles)
{
Console.Out.WriteLine($" {file}");
}
if (CopyFiles(Program.Location, UserBinPath, DocsList, out copiedFiles))
{
copiedCount = copiedFiles.Count;
foreach (var file in copiedFiles)
{
Console.Out.WriteLine($" {file}");
}
}
Program.LogEvent($"Deployment to '{UserBinPath}' succeeded.", EventLogEntryType.Information);
Console.Out.WriteLine($" {copiedFiles.Count} file(s) copied");
Console.Out.WriteLine($" {copiedCount} file(s) copied");
}
else if (_isForced)
{
@ -317,15 +348,27 @@ namespace Microsoft.Alm.Cli
if (CygwinPath != null && Directory.Exists(CygwinPath))
{
if (CopyFiles(Program.Location, CygwinPath, out copiedFiles))
if (CopyFiles(Program.Location, CygwinPath, FileList, out copiedFiles))
{
int copiedCount = copiedFiles.Count;
foreach (var file in copiedFiles)
{
Console.Out.WriteLine($" {file}");
}
if (CopyFiles(Program.Location, CygwinPath, DocsList, out copiedFiles))
{
copiedCount = copiedFiles.Count;
foreach (var file in copiedFiles)
{
Console.Out.WriteLine($" {file}");
}
}
Program.LogEvent($"Deployment to '{CygwinPath}' succeeded.", EventLogEntryType.Information);
Console.Out.WriteLine($" {copiedFiles.Count} file(s) copied");
Console.Out.WriteLine($" {copiedCount} file(s) copied");
}
else if (_isForced)
{
@ -522,14 +565,28 @@ namespace Microsoft.Alm.Cli
Console.Out.WriteLine();
Console.Out.WriteLine($"Removing from '{installation.Path}'.");
if (CleanFiles(installation.Libexec, out cleanedFiles))
if (CleanFiles(installation.Libexec, FileList, out cleanedFiles))
{
int cleanedCount = cleanedFiles.Count;
foreach (var file in cleanedFiles)
{
Console.Out.WriteLine($" {file}");
}
Console.Out.WriteLine($" {cleanedFiles.Count} file(s) cleaned");
// clean help documents
if (Directory.Exists(installation.Doc)
&& CleanFiles(installation.Doc, DocsList, out cleanedFiles))
{
cleanedCount += cleanedFiles.Count;
foreach (var file in cleanedFiles)
{
Console.Out.WriteLine($" {file}");
}
}
Console.Out.WriteLine($" {cleanedCount} file(s) cleaned");
}
else if (_isForced)
{
@ -550,14 +607,26 @@ namespace Microsoft.Alm.Cli
Console.Out.WriteLine();
Console.Out.WriteLine($"Removing from '{UserBinPath}'.");
if (CleanFiles(UserBinPath, out cleanedFiles))
if (CleanFiles(UserBinPath, FileList, out cleanedFiles))
{
int cleanedCount = cleanedFiles.Count;
foreach (var file in cleanedFiles)
{
Console.Out.WriteLine($" {file}");
}
Console.Out.WriteLine($" {cleanedFiles.Count} file(s) cleaned");
if (CleanFiles(UserBinPath, DocsList, out cleanedFiles))
{
cleanedCount += cleanedFiles.Count;
foreach (var file in cleanedFiles)
{
Console.Out.WriteLine($" {file}");
}
}
Console.Out.WriteLine($" {cleanedCount} file(s) cleaned");
}
else if (_isForced)
{
@ -575,14 +644,26 @@ namespace Microsoft.Alm.Cli
if (CygwinPath != null && Directory.Exists(CygwinPath))
{
if (CleanFiles(CygwinPath, out cleanedFiles))
if (CleanFiles(CygwinPath, FileList, out cleanedFiles))
{
int cleanedCount = cleanedFiles.Count;
foreach (var file in cleanedFiles)
{
Console.Out.WriteLine($" {file}");
}
Console.Out.WriteLine($" {cleanedFiles.Count} file(s) cleaned");
if (CleanFiles(CygwinPath, DocsList, out cleanedFiles))
{
cleanedCount += cleanedFiles.Count;
foreach (var file in cleanedFiles)
{
Console.Out.WriteLine($" {file}");
}
}
Console.Out.WriteLine($" {cleanedCount} file(s) cleaned");
}
}
@ -673,7 +754,7 @@ namespace Microsoft.Alm.Cli
return true;
}
private bool CleanFiles(string path, out List<string> cleanedFiles)
private bool CleanFiles(string path, IReadOnlyList<string> files, out List<string> cleanedFiles)
{
cleanedFiles = new List<string>();
@ -685,7 +766,7 @@ namespace Microsoft.Alm.Cli
try
{
foreach (string file in Files)
foreach (string file in files)
{
string target = Path.Combine(path, file);
@ -705,7 +786,7 @@ namespace Microsoft.Alm.Cli
}
}
private bool CopyFiles(string srcPath, string dstPath, out List<string> copiedFiles)
private bool CopyFiles(string srcPath, string dstPath, IReadOnlyList<string> files, out List<string> copiedFiles)
{
copiedFiles = new List<string>();
@ -719,7 +800,7 @@ namespace Microsoft.Alm.Cli
{
try
{
foreach (string file in Files)
foreach (string file in files)
{
Git.Trace.WriteLine($"copy '{file}' from '{srcPath}' to '{dstPath}'.");

Просмотреть файл

@ -23,11 +23,12 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
**/
using Microsoft.Alm.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Alm.Authentication;
namespace Microsoft.Alm.Cli
{
@ -50,7 +51,7 @@ namespace Microsoft.Alm.Cli
internal const string CommandUninstall = "uninstall";
internal const string CommandVersion = "version";
private static readonly List<string> CommandList = new List<string>
private static readonly IReadOnlyList<string> CommandList = new string[]
{
CommandApprove,
CommandClear,
@ -343,55 +344,34 @@ namespace Microsoft.Alm.Cli
private static void PrintHelpMessage()
{
Console.Out.WriteLine("usage: git credential-manager [" + String.Join("|", CommandList) + "] [<args>]");
Console.Out.WriteLine();
Console.Out.WriteLine("Command Line Options:");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + CommandDeploy + " Deploys the " + Title + " package and sets");
Console.Out.WriteLine(" Git configuration to use the helper.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + Installer.ParamPathKey + " Specifies a path for the installer to deploy to.");
Console.Out.WriteLine(" If a path is provided, the installer will not seek additional");
Console.Out.WriteLine(" Git installations to modify.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + Installer.ParamPassiveKey + " Instructs the installer to not prompt the user for input");
Console.Out.WriteLine(" during deployment and restricts output to error messages only.");
Console.Out.WriteLine(" When combined with " + Installer.ParamForceKey + " all output is eliminated; only the");
Console.Out.WriteLine(" return code can be used to validate success.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + Installer.ParamForceKey + " Instructs the installer to proceed with deployment even if");
Console.Out.WriteLine(" prerequisites are not met or errors are encountered.");
Console.Out.WriteLine(" When combined with " + Installer.ParamPassiveKey + " all output is eliminated; only the");
Console.Out.WriteLine(" return code can be used to validate success.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + CommandRemove + " Removes the " + Title + " package");
Console.Out.WriteLine(" and unsets Git configuration to no longer use the helper.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + Installer.ParamPathKey + " Specifies a path for the installer to remove from.");
Console.Out.WriteLine(" If a path is provided, the installer will not seek additional");
Console.Out.WriteLine(" Git installations to modify.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + Installer.ParamPassiveKey + " Instructs the installer to not prompt the user for input");
Console.Out.WriteLine(" during removal and restricts output to error messages only.");
Console.Out.WriteLine(" When combined with " + Installer.ParamForceKey + " all output is eliminated; only the");
Console.Out.WriteLine(" return code can be used to validate success.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + Installer.ParamForceKey + " Instructs the installer to proceed with removal even if");
Console.Out.WriteLine(" prerequisites are not met or errors are encountered.");
Console.Out.WriteLine(" When combined with " + Installer.ParamPassiveKey + " all output is eliminated; only the");
Console.Out.WriteLine(" return code can be used to validate success.");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + CommandDelete + " Removes stored credentials for a given URL.");
Console.Out.WriteLine(" Any future attempts to authenticate with the remote will require");
Console.Out.WriteLine(" authentication steps to be completed again.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git credential-manager clear <url>`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + CommandVersion + " Displays the current version.");
const string HelpFileName = "git-credential-manager.html";
Console.Out.WriteLine();
PrintConfigurationHelp();
Console.Out.WriteLine();
Console.Out.WriteLine("usage: git credential-manager [" + String.Join("|", CommandList) + "] [<args>]");
List<Git.GitInstallation> installations;
if (Git.Where.FindGitInstallations(out installations))
{
foreach (var installation in installations)
{
if (Directory.Exists(installation.Doc))
{
string doc = Path.Combine(installation.Doc, HelpFileName);
// if the help file exists, send it to the operating system to display to the user
if (File.Exists(doc))
{
Git.Trace.WriteLine($"opening help documentation '{doc}'.");
Process.Start(doc);
return;
}
}
}
}
Console.Error.WriteLine("Unable to open help documentation.");
Git.Trace.WriteLine("failed to open help documentation.");
}
private static void Remove()

Просмотреть файл

@ -0,0 +1,19 @@
:: Want to update this thing and don't know how?
:: Check http://ss64.com/nt/syntax.html
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET assets=%~dp0..\Assets
SET dstdir=%~dp0..\Deploy
SET srcdir=%~dp0..\Docs
IF NOT EXIST "%dstdir%" (
mkdir "%dstdir%" > nul 1>&2
)
IF EXIST %srcdir% (
(WHERE pandoc > nul 1>&2) && (pandoc --from=markdown --include-in-header="%assets%\help.css" --to=html --normalize --output="%dstdir%\git-credential-manager.html" "%srcdir%\CredentialManager.md" "%srcdir%\Configuration.md" "%srcdir%\Faq.md" "%srcdir%\Automation.md" "%srcdir%\Development.md" > nul 1>&2) && (ECHO git-credential-manager.html generated.)
(WHERE pandoc > nul 1>&2) && (pandoc --from=markdown --include-in-header="%assets%\help.css" --to=html --normalize --output="%dstdir%\git-askpass.html" "%srcdir%\Askpass.md" "%srcdir%\Configuration.md" "%srcdir%\Faq.md" "%srcdir%\Automation.md" "%srcdir%\Development.md" > nul 1>&2) && (ECHO git-askpass.html generated.)
)
EXIT /B 0

Просмотреть файл

@ -845,81 +845,6 @@ namespace Microsoft.Alm.Cli
}
}
private static void PrintConfigurationHelp()
{
Console.Out.WriteLine("Git Configuration Options:");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigAuthortyKey + " Defines the type of authentication to be used.");
Console.Out.WriteLine(" Supports Auto, Basic, AAD, MSA, and Integrated.");
Console.Out.WriteLine(" Default is Auto.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential.microsoft.visualstudio.com." + ConfigAuthortyKey + " AAD`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigInteractiveKey + " Specifies if user can be prompted for credentials or not.");
Console.Out.WriteLine(" Supports Auto, Always, or Never. Defaults to Auto.");
Console.Out.WriteLine(" Only used by AAD, MSA, and GitHub authority.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential.microsoft.visualstudio.com." + ConfigInteractiveKey + " never`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigUseModalPromptKey + " Forces authentication to use a modal dialog instead of");
Console.Out.WriteLine(" asking for credentials at the command prompt.");
Console.Out.WriteLine(" Defaults to TRUE.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential." + ConfigUseModalPromptKey + " true`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigValidateKey + " Causes validation of credentials before supplying them");
Console.Out.WriteLine(" to Git. Invalid credentials get a refresh attempt");
Console.Out.WriteLine(" before failing. Incurs some minor overhead.");
Console.Out.WriteLine(" Defaults to TRUE. Ignored by Basic authority.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential.microsoft.visualstudio.com." + ConfigValidateKey + " false`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigPreserveCredentialsKey + " Prevents the deletion of credentials even when they are");
Console.Out.WriteLine(" reported as invalid by Git. Can lead to lockout situations once credentials");
Console.Out.WriteLine(" expire and until those credentials are manually removed.");
Console.Out.WriteLine(" Defaults to FALSE.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential.visualstudio.com." + ConfigPreserveCredentialsKey + " true`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigUseHttpPathKey + " Causes the path portion of the target URI to considered meaningful.");
Console.Out.WriteLine(" By default the path portion of the target URI is ignore, if this is set to true");
Console.Out.WriteLine(" the path is considered meaningful and credentials will be store for each path.");
Console.Out.WriteLine(" Defaults to FALSE.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential.bitbucket.com." + ConfigUseHttpPathKey + " true`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigHttpProxyKey + " Causes the proxy value to be considered when evaluating.");
Console.Out.WriteLine(" credential target information. A proxy setting should established if use of a");
Console.Out.WriteLine(" proxy is required to interact with Git remotes.");
Console.Out.WriteLine(" The value should the URL of the proxy server.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential.github.com." + ConfigUseHttpPathKey + " https://myproxy:8080`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigWritelogKey + " Enables trace logging of all activities. Logs are written to");
Console.Out.WriteLine(" the local .git/ folder at the root of the repository.");
Console.Out.WriteLine(" Defaults to FALSE.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential." + ConfigWritelogKey + " true`");
Console.Out.WriteLine();
Console.Out.WriteLine(" " + ConfigNamespaceKey + " Sets the namespace for stored credentials.");
Console.Out.WriteLine(" By default the GCM uses the 'git' namespace for all stored credentials, setting this");
Console.Out.WriteLine(" configuration value allows for control of the namespace used globally, or per host.");
Console.Out.WriteLine();
Console.Out.WriteLine(" `git config --global credential." + ConfigNamespaceKey + " name`");
Console.Out.WriteLine();
Console.Out.WriteLine("Sample Configuration:");
Console.Out.WriteLine();
Console.Out.WriteLine(@" [credential ""microsoft.visualstudio.com""]");
Console.Out.WriteLine(@" " + ConfigAuthortyKey + " = AAD");
Console.Out.WriteLine(@" " + ConfigInteractiveKey + " = never");
Console.Out.WriteLine(@" " + ConfigValidateKey + " = false");
Console.Out.WriteLine(@" [credential ""visualstudio.com""]");
Console.Out.WriteLine(@" " + ConfigAuthortyKey + " = MSA");
Console.Out.WriteLine(@" [credential]");
Console.Out.WriteLine(@" helper = manager");
Console.Out.WriteLine(@" " + ConfigWritelogKey + " = true");
}
private static void PrintVersion()
{
Console.Out.WriteLine("{0} version {1}", Title, Version.ToString(3));

Просмотреть файл

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>0e1864bd-c462-4600-9c29-06bf8562a9b2</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>CommonShared</Import_RootNamespace>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>0e1864bd-c462-4600-9c29-06bf8562a9b2</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="CommonShared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

12
Docs/Askpass.md Normal file
Просмотреть файл

@ -0,0 +1,12 @@
# Git Askpass for Windows
[Git Askpass for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows) (Askpass) provides secure Git credential storage for Windows. Askpass provides multi-factor authentication support for [Visual Studio Team Services](https://www.visualstudio.com/), [Team Foundation Server](https://www.visualstudio.com/en-us/products/tfs-overview-vs.aspx), and [GitHub](https://www.github.com).
# Usage
Generally speaking, Git will use Git Askpass for Windows and you will only need to interact with any authentication dialogs asking for credentials. As much as possible, Askpass attempts to stay out of sight and out of mind. We believe that Askpass is doing its best job when you forget you're depending on it at all.
git askpass
For Git to use Askpass correctly, the `GIT_ASKPASS` environment variable needs contain the full path to the `git-askpass.exe` executable (example: `setx GIT_ASKPASS "C:\Program Files\Git\mingw64\libexec\git-core\askpass.exe"`). SSH can also be configured to use Askpass in the same manner using the `SSH_ASKPASS` environment variable; however, SSH currently will not use Askpass if it detects a TTY console (ala the ability to just ask on the console).

29
Docs/Automation.md Normal file
Просмотреть файл

@ -0,0 +1,29 @@
# Build Agents and Automation
Build agents, and other automation, often require specialized setup and configuration. While there is detailed documentation on [GCM configuration options](Docs/Configuration.md), below are common recommendations for settings agents often require to operate.
## Recommendations
Build agents cannot manage modal dialogs, therefore we recommended the following configuration.
git config --global credential.interactive never
Build agents often need to minimize the amount of network traffic they generate.
To avoid Microsoft Account vs. Azure Active Directory look-up against a Visual Studio Team Services account use...
... for Azure Directory backed authentication:
git config --global credential.authority Azure
... for Microsoft Account backed authentication:
git config --global credential.authority Microsoft
If your agents rely on an on premise instance of Team Foundation Server and [Windows Domain Authentication](https://msdn.microsoft.com/en-us/library/ee253152(v=bts.10).aspx), use:
git config --global credential.authority Windows
To avoid unnecessary service account credential validation, when relying on Microsoft Account or Azure Active Directory use:
git config --global credential.validate false

120
Docs/Configuration.md Normal file
Просмотреть файл

@ -0,0 +1,120 @@
# Configuration Options
For the majority of users, the default configuration is the correct configuration. There will always be those who need special features or the ability to tweak how a service operates.
The Git Credential Manager for Windows [GCM] can be configured using Git's configuration files, and follows all of the same rules Git does when consuming the files. Global configuration settings override system configuration settings, and local configuration settings override global settings; and because the configuration details exist within Git's configuration files you can use Git's `git config` utility to set, unset, and alter the setting values.
The GCM honors several levels of settings, in addition to the standard local \> global \> system tiering Git uses. Since the GCM is HTTPS based, it'll also honor URL specific settings. Regardless, all of the GCM's configuration settings begin with the term `credential`.
Regardles, the GCM will only be used by Git if the GCM is installed and the key/value pair `credential.helper manager` is present in Git's configuration.
For example:
> `credential.microsoft.visualstudio.com.namespace` is more specific than `credential.visualstudio.com.namespace`, which is more specific than `credential.namespace`.
In the examples above, the `credential.namespace` setting would affect any remote repository; the `credential.visualstudio.com.namespace` would affect any remote repository in the domain, and/or any subdomain (including `www.`) of, 'visualstudio.com'; where as the the `credential.microsoft.visualstudio.com.namespace` setting would only be applied to remote repositories hosted at 'microsoft.visualstudio.com'.
For the complete list of settings the GCM knows how to check for an apply, see the list below.
# Configuration Setting Names
### authority
Defines the type of authentication to be used.
Supports Auto, Basic, AAD, MSA, and Integrated.
Defaults to _Auto_.
git config --global credential.microsoft.visualstudio.com.authority AAD
### httpProxy
Causes the proxy value to be considered when evaluating credential target information. A proxy setting should established if use of a proxy is required to interact with Git remotes.
The value should the URL of the proxy server.
git config --global credential.github.com.useHttpPath https://myproxy:8080
### interactive
Specifies if user can be prompted for credentials or not.
Supports Auto, Always, or Never. Defaults to Auto.
Only used by AAD, MSA, and GitHub authority.
`git config --global credential.microsoft.visualstudio.com.interactive never`
### modalPrompt
Forces authentication to use a modal dialog instead of asking for credentials at the command prompt.
Defaults to _true_.
git config --global credential.modalPrompt true
### namespace
Sets the namespace for stored credentials.
By default the GCM uses the 'git' namespace for all stored credentials, setting this configuration value allows for control of the namespace used globally, or per host.
git config --global credential.namespace name
### preserve
Prevents the deletion of credentials even when they are reported as invalid by Git. Can lead to lockout situations once credentials expire and until those credentials are manually removed.
Defaults to _false_.
git config --global credential.visualstudio.com.preserve true
### useHttpPath
Causes the path portion of the target URI to considered meaningful.
By default the path portion of the target URI is ignore, if this is set to true the path is considered meaningful and credentials will be store for each path.
Defaults to _false_.
git config --global credential.bitbucket.com.useHttpPath true
### validate
Causes validation of credentials before supplying them to Git. Invalid credentials get a refresh attempt before failing. Incurs some minor overhead.
Defaults to _true_. Ignored by _Basic_ authority.
git config --global credential.microsoft.visualstudio.com.validate false
### writelog
Enables trace logging of all activities. Logs are written to the local .git/ folder at the root of the repository.
Defaults to _false_.
git config --global credential.writelog true
## Sample Configuration
```INI
[credential "microsoft.visualstudio.com"]
authority = AAD
interactive = never
preserve = true
validate = false
[credential "visualstudio.com"]
authority = MSA
[credential]
helper = manager
writelog = true
```

81
Docs/CredentialManager.md Normal file
Просмотреть файл

@ -0,0 +1,81 @@
# Git Credential Manager for Windows
The [Git Credential Manager for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows) (GCM) provides secure Git credential storage for Windows. GCM provides multi-factor authentication support for [Visual Studio Team Services](https://www.visualstudio.com/), [Team Foundation Server](https://www.visualstudio.com/en-us/products/tfs-overview-vs.aspx), and [GitHub](https://www.github.com).
# Usage
Generally speaking, Git will use the Git Credential Manager for Windows and you will only need to interact with any authentication dialogs asking for credentials. As much as possible, the GCM attempts to stay out of sight and out of mind. We believe that the GCM is doing its best job when you forget you're depending on it at all.
Assuming the GCM has been installed, using your favorite Windows console (Command Prompt, PowerShell, ConEmu, etc), use the following command to interact directly with the GCM.
git credential-manager [<command> [<args>]]
## Commands
### delete
Removes stored credentials for a given URL. Any future attempts to authenticate with the remote will require authentication steps to be completed again.
### deploy _[--path \<installion_path\>] [--passive] [--force]_
Deploys the Git Credential Manager for Windows package and sets Git configuration to use the helper.
**--path \<installion_path\>**
Specifies a path (\<installion_path\>) for the installer to deploy to. If a path is provided, the installer will not seek additional Git installations to modify.
**--passive**
Instructs the installer to not prompt the user for input during deployment and restricts output to error messages only.
When combined with *--force* all output is eliminated; only the return code can be used to validate success.
**--force**
Instructs the installer to proceed with deployment even if prerequisites are not met or errors are encountered.
When combined with *--passive* all output is eliminated; only the return code can be used to validate success.
### remove _[--path \<installion_path\>] [--passive] [--force]_
Removes the Git Credential Manager for Windows package and unsets Git configuration to no longer use the helper.
**--path \<installion_path\>**
Specifies a path (\<installion_path\>) for the installer to remove from. If a path is provided, the installer will not seek additional Git installations to modify.
**--passive**
Instructs the installer to not prompt the user for input during removal and restricts output to error messages only.
When combined with *--force* all output is eliminated; only the return code can be used to validate success.
**--force**
Instructs the installer to proceed with removal even if prerequisites are not met or errors are encountered.
When combined with *--passive* all output is eliminated; only the return code can be used to validate success.
### version
Displays the current version.
### clear
Synonym for **delete**.
### install
Synonym for **deploy**.
### uninstall
Synonym for **remove**.
### get / store / erase / fill / approve / reject
Commands for interaction with Git.

93
Docs/Development.md Normal file
Просмотреть файл

@ -0,0 +1,93 @@
# Development and Debugging
Development on the GCM geenrally requires Visual Studio 2015 or newer. Luckily, Visual Studio offers a free [Community Edition](https://www.visualstudio.com/products/visual-studio-community-vs), for those of us who do not have an enterpise copy installed.
## Getting Started
The easiest way to get started is to:
1. Install Visual Studio
2. [Clone the repository](https://github.com/Microsoft/Git-Credential-Manager-for-Windows.git)
3. Open the solution file (Microsoft.Alm.sln) using Visual Studio
4. Right-click the solution node in Solution Explorer and choose 'Restore NuGet Packages'. This will download and setup all of the dependencies.
5. Right-click the 'Cli-CredentialHelper' project in Solution Explorer and select 'Properties'.
6. In the "Properties" window, select the 'Debug' tab from the left side.
7. In the "Properties: Debug" window, add the word "get" to the 'Command line arguments:' text box.
8. Close the "Properties" window.
5. Hit \<F5\>, or 'Debug' \>\> 'Start Debugging' from the top menu of Visual Studio.
### Debugging Code
Once the GCM starts you'll be presented with a very *unsatifying* console window. This is because the GCM expects to be launched by Git, not directly. However, it is easy to play the role of Git. The GCM expects Git to supply at least two pieces of information: the protocol being use and the host name for which the current operation is happening.
An example of faking Git request for GitHub credentials:
```
protocol=https
host=github.com
```
Notice the **blank last line**. That empty line is how Git and the GCM notify the otherside that they're done sending data. Until an empty line is sent to the GCM, it'll keep attempting to read from standard input.
Once the blank line is fed to the GCM it'll "do its thing". Ideally, you can watch it work, so that you can learn how it works and then improve it. To do so, place a break point in the `Main` method of the 'Program.cs' file. Doing so will allow you to "break in" when the execition pointer reaches your break point. You'll notice that the GCM doesn't read from standard input immediately; instead it does some setup work to determine what it expected of it and then only reads from standard input if it is expected to.
In the case of `git credential-manager get`, the `Main` method will call the `Get` method, which in turn will allocate a new `OperationArguments` object and initialize it with the process' standard input pipe. This is when stanard input will be consumed by the GCM.
### Notable Code
* `Program.LoadOperationArguments` method is where the GCM scans, parses, and consumes environmental and configuraiton setting values.
* `Program.QueryCredentials` method is where the "action" happens.
* `OperationArguments` class is where the GCM consumes standard input and keeps internal state.
## Installer (setup.exe)
Changes to the installer (setup.exe) requires [Inno Setup Compiler 5.5.6](http://www.jrsoftware.org/isinfo.php) or later to compile. Additionally, the [IDP plugin for Inno Setup](https://mitrichsoftware.wordpress.com/inno-setup-tools/inno-download-plugin/) is also required.
The setup compiler pulls content from the "Deploy/" folder, therefore a completed Debug or Release build needs to have been completed prior to running the setup compiler. Content in the "Deploy/" folder will be used in the setup compilation.
## Microsoft.Alm.Authentication NuGet Package
The [Microsoft.Alm.Authentication](https://www.nuget.org/packages/Microsoft.Alm.Authentication/) NuGet package is automatically created when the Microsoft.Alm.Authentication project is built. The generated .nupkg files can be found in the "Debug/" or "Release/" (depending on your build target) under "Microsoft.Alm.Authentication/bin/". Both the binary and symbold packages are automatically created.
Updates to the NuGet package stream are reserved for officially built binaries.
## Signing
Only Microsoft can sign binaries with the Microsoft certificate. Therefore, while anyone can build and use their own binaies from the GCM souce code, only officially releases binaries will be signed by Microsoft.
## Documents
The documentation is formatted using [markdown](https://daringfireball.net/projects/markdown/syntax) and generated using [Pandoc](http://http://pandoc.org/).
## Logging
To enable logging, use the following:
git config --global credential.writelog true
Log files will be written to the repo's local `.git/` folder.
Debug build of the GCM will perform extended logging to the console, which is convenient for debugging purposes bug too noisy for day-to-day usage.
## Contribute
There are many ways to contribute.
* [Submit bugs](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues) and help us verify fixes as they are checked in.
* Review [code changes](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/pulls).
* Contribute bug fixes and features.
### Code Contributions
For code contributions, you will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you grant us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under the appropriate copyright.
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit <https://cla.microsoft.com> to sign digitally. Alternatively, download the agreement [Microsoft Contribution License Agreement.pdf](https://cla.microsoft.com/cladoc/microsoft-contribution-license-agreement.pdf), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your GitHub user name along with the agreement. Once we have received the signed CLA, we'll review the request.
### Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## License
This project uses the [MIT License](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/blob/master/LICENSE.txt).

56
Docs/Faq.md Normal file
Просмотреть файл

@ -0,0 +1,56 @@
# FAQ
Frequently asked questions collected from our [issues page](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues), our [Twitter feed](https://twitter.com/microsoftgit), and other sources. Please look through this list of questions-and-answers before posting a new issue on a topic.
## Q: Why am always prompted for my username and password?
Most likely, your environment is not configured correctly. You can verify that your environment is configured correctly by running `git config --list` and looking for `credential.helper=manager`. If you do not see the line, then you know that Git does not know about the Git Credential Manager. You can configure Git to use the Credential Manager by running `git config credential.helper manager`.
## Q: Why does my GUI freeze when I push, pull, or fetch?
Most likely reason is that your GUI “shells out” to git.exe to perform Git operations. When it does so, it cannot respond to the command line prompts for username and password like a real user can. To avoid being asked for your credentials on the command line, and instead be asked via a modal dialog youll need to [configure the Credential Manager](Configuration.md#modalprompt).
1. Decide if you want this to be a global setting (all of your repositories) or a local setting (just one repository).
2. Start your favorite shell. (cmd, powershell, bash, etc.)
3. Update your settings, so that Git Credential Manager knows to display a dialog and not prompt at the command line:
* If youve decided this is a global setting run `git config --global credential.modalprompt true`.
* If youve decided this a per repository setting, `cd` to your repo and in that repo run `git config credential.modalprompt true`.
## Q: Why am I not seeing my SSH keys being saved?
The Git Credential Manager does not *yet* support secure storage for SSH keys. It is something we hope to implement, but it has not been a priority. If you feel otherwise, please comment on the [SSH Key support issue](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/25) which is already open.
## Q: Is there a NuGet Package available?
Yes there is: <https://www.nuget.org/packages/Microsoft.Alm.Authentication>. It only supports the core authentication library, but if you're looking to extend the GCM then it is likely exactly what you're after.
## Q: Why doesnt Git Credential Manager work on Windows XP, Mac OS, or Linux?
The Git Credential Manager does not work on Windows XP, Max OS, or Linux because we had to scope our work and we decided to support the same operating systems that Visual Studio support. Why Visual Studio? Well, because it is our favorite IDE and in order to support [Visual Studio Team Services](https://www.visualstudio.com/en-us/products/visual-studio-team-services-vs.aspx) we had to use the [Azure Directory Authentication Libraries](https://github.com/AzureAD) which only have multi-factor interactive logon support in their .NET libraries. Using .NET means using Visual Studio (which we love anyways) and using Visual Studio means Windows 7 or newer.
## Q: Will there ever be support for Windows XP, Mac OS, or Linux?
We can safely say that we have no interest in supporting Windows XP. Even [Microsoft has ended support for Windows XP](https://windows.microsoft.com/en-us/windows/end-support-help). Support for Mac OS and Linux are handled by [Microsoft Git Credential Manager for Mac and Linux](https://github.com/Microsoft/Git-Credential-Manager-for-Mac-and-Linux).
## Q: Why is my distribution/version of Git not supported? Why is Git for Windows favored?
The Credential Manager deployment helpers (`install.cmd` and `Setup.exe`) are focused on support for [Git for Windows](https://github.com/git-for-windows) because Git for Windows conforms to the expected/normal behavior of software on Windows. It is easy to detect, has predictable installation location, etc. This makes supporting it cheaper and more reliable.
That said, so long as your favorite version of Git supports Gits git-credential flow, it is supported by the Git Credential Manager for Windows. Setup will have to be manual, and if you find a way to script it we would love to have you contribute that to our project.
1. Copy the contents of the `gcm-<version>.zip` to your Gits /bin folder. This varies per distribution, but it is likely next to other git tools like `git-status.exe`.
2. Update your Git configuration by running `git config --global credential.helper manager`.
## Q: I thought Microsoft was maintaining this, why does the GCM not work as expected with TFS?
Team Foundation Server, when deployed on a corporate Active Directory, uses the [Microsoft Kerberos](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378747(v=vs.85).aspx) protocol for authentication. Git doesn't "speak" the Kerberos protocol.
Git can be convinced to "forward" domain credentials by supplying a blank credentials (username and password). Since, by default, the GCM doesn't allow for a blank credentials, you will need to configure it to allow for them. To do so, update your Git configuration by running `git config --global credential.tfs.fabrikam.com.integrated true`.
Once updated, the new configuration tells the GCM to only forward domain credentials. If you set `credential.integrated true`, every domain will be assumed to support domain credentials. Most likely, this is **not** what you want. Therefore, it strongly suggested that you restrict the configuration setting to the URL of your TFS Git host.
## Q: Why doesn't SourceTree use the credentials in the GCM?
You need to configure SourceTree to use the version of Git installed for the entire system. By default, SourceTree uses a local copy of portable Git.
To fix this go to Tools -> Options -> Git and click the "Use System Git" button. This works in v1.8.3.0 of SourceTree.

47
Docs/Index.md Normal file
Просмотреть файл

@ -0,0 +1,47 @@
# Git Credential Manager for Windows
The [Git Credential Manager for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows) (GCM) provides secure Git credential storage for Windows. GCM provides multi-factor authentication support for [Visual Studio Team Services](https://www.visualstudio.com/), [Team Foundation Server](Faq.md#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs), and [GitHub](https://www.github.com).
This project includes:
* Secure password storage in the Windows Credential Store
* Multi-factor authentication support for Visual Studio Team Services
* Two-factor authentication support for GitHub
* Personal Access Token generation and usage support for Visual Studio Team Services and GitHub
* Non-interactive mode support for Visual Studio Team Services backed by Azure Directory
* Kerberos authentication for Team Foundation Server ([see notes](#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs))
* Optional settings for build agent optimization
This is a community project so feel free to contribute ideas, submit bugs, fix bugs, or code new features. For detailed information on how the GCM works go to the [wiki](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/wiki/How-the-Git-Credential-Managers-works).
## Download and Install
To use the GCM, you can download the [latest installer](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/latest). To install, double-click Setup.exe and follow the instructions presented.
When prompted to select your terminal emulator for Git Bash you should choose the Windows' default console window, or make sure GCM is [configured to use modal dialogs](Configuration.md#modalprompt). GCM cannot prompt you for credentials, at the console, in a MinTTY setup.
## How to use
You don't. It [magically](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/31) works when credentials are needed. For example, when pushing to [Visual Studio Team Services](https://www.visualstudio.com), it automatically opens a window and initializes an oauth2 flow to get your token.
### Manual Installation
Note for users with special installation needs, you can still extract the `gcm-<version>.zip` file and run install.cmd from an administrator command prompt. This allows specification of the installation options explained below.
### Build and Install from Sources
To build and install the GCM yourself, clone the sources, open the solution file in Visual Studio, and build the solution. All necessary components will be copied from the build output locations into a `.\Deploy` folder at the root of the solution. From an elevated command prompt in the `.\Deploy` folder issue the following command `git-credential-manager install`.
[Various options](Configuration.md) are available for uniquely configured systems, like automated build systems. For systems with a **non-standard placement of Git** use the `--path <git>` parameter to supply where Git is located and thus where the GCM should be deployed to. For systems looking to **avoid checking for the Microsoft .NET Framework** and other similar prerequisites use the `--force` option. For systems looking for **silent installation without any prompts**, use the `--passive` option.
#### Additional Resources
* [Configuration Options](Configuration.md)
* [Usage Options](Usage.md)
* [Build Agent and Automation Support](Automation.md)
* [Frequently Asked Questions](Faq.md)
* [Development and Debugging](Development.md)
## License
This project uses the [MIT License](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/blob/master/LICENSE.txt).

Просмотреть файл

@ -222,7 +222,6 @@
<ItemGroup>
<Resource Include="Assets\octocat-mark.ico" />
</ItemGroup>
<Import Project="..\CommonShared\CommonShared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>

Просмотреть файл

@ -104,7 +104,6 @@
<Name>Microsoft.Alm.Git</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\CommonShared\CommonShared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- Produce a nuget package of this assembly -->
<Import Project="..\packages\MSBuildTasks.*\tools\MSBuild.Community.Tasks.Targets" />

Просмотреть файл

@ -42,6 +42,9 @@ namespace Microsoft.Alm.Git
internal const string Version1Config32Path = @"etc\gitconfig";
internal const string Version2Config32Path = @"mingw32\etc\gitconfig";
internal const string Version2Config64Path = @"mingw64\etc\gitconfig";
internal const string Version1Doc32Path = @"doc\git\html";
internal const string Version2Doc32Path = @"mingw32\share\doc\git-doc";
internal const string Version2Doc64Path = @"mingw64\share\doc\git-doc";
internal const string Version1Libexec32Path = @"libexec\git-core\";
internal const string Version2Libexec32Path = @"mingw32\libexec\git-core";
internal const string Version2Libexec64Path = @"mingw64\libexec\git-core";
@ -81,15 +84,23 @@ namespace Microsoft.Alm.Git
{ KnownGitDistribution.GitForWindows32v2, AllVersionShPath },
{ KnownGitDistribution.GitForWindows64v2, AllVersionShPath },
};
public static readonly IReadOnlyDictionary<KnownGitDistribution, string> CommonDocPaths
= new Dictionary<KnownGitDistribution, string>
{
{ KnownGitDistribution.GitForWindows32v1, Version1Doc32Path },
{ KnownGitDistribution.GitForWindows32v2, Version2Doc32Path },
{ KnownGitDistribution.GitForWindows64v2, Version2Doc64Path },
};
internal GitInstallation(string path, KnownGitDistribution version)
{
Debug.Assert(!String.IsNullOrWhiteSpace(path), "The `path` parameter is null or invalid.");
Debug.Assert(CommonConfigPaths.ContainsKey(version), "The `version` parameter not found in `CommonConfigPaths`.");
Debug.Assert(CommonCmdPaths.ContainsKey(version), "The `version` parameter not found in `CommonCmdPaths`.");
Debug.Assert(CommonGitPaths.ContainsKey(version), "The `version` parameter not found in `CommonGitPaths`.");
Debug.Assert(CommonLibexecPaths.ContainsKey(version), "The `version` parameter not found in `CommonLibExecPaths`.");
Debug.Assert(CommonShPaths.ContainsKey(version), "The `version` parameter not found in `CommonShPaths`.");
Debug.Assert(!String.IsNullOrWhiteSpace(path), $"The `{nameof(path)}` parameter is null or invalid.");
Debug.Assert(CommonConfigPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonConfigPaths)}`.");
Debug.Assert(CommonCmdPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonCmdPaths)}`.");
Debug.Assert(CommonGitPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonGitPaths)}`.");
Debug.Assert(CommonLibexecPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonLibexecPaths)}`.");
Debug.Assert(CommonShPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonShPaths)}`.");
Debug.Assert(CommonDocPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonDocPaths)}`.");
path = path.TrimEnd('\\');
@ -119,6 +130,7 @@ namespace Microsoft.Alm.Git
Version = version;
_cmd = null;
_config = null;
_doc = null;
_git = null;
_libexec = null;
_sh = null;
@ -148,6 +160,18 @@ namespace Microsoft.Alm.Git
}
}
private string _cmd;
public string Doc
{
get
{
if (_doc == null)
{
_doc = System.IO.Path.Combine(Path, CommonDocPaths[Version]);
}
return _doc;
}
}
private string _doc;
public string Git
{
get

Просмотреть файл

@ -55,7 +55,6 @@
<Compile Include="Trace.cs" />
<Compile Include="Where.cs" />
</ItemGroup>
<Import Project="..\CommonShared\CommonShared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Просмотреть файл

@ -29,18 +29,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cli-Askpass", "Cli-AskPass\
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Cli-Shared", "Cli-Shared\Cli-Shared.shproj", "{DBD202C3-94D5-49D3-8ED1-C72637BA7D90}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CommonShared", "CommonShared\CommonShared.shproj", "{0E1864BD-C462-4600-9C29-06BF8562A9B2}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Cli-Shared\Cli-Shared.projitems*{0653670e-b33a-4ebe-92b8-04c93f43cae0}*SharedItemsImports = 4
CommonShared\CommonShared.projitems*{0653670e-b33a-4ebe-92b8-04c93f43cae0}*SharedItemsImports = 4
CommonShared\CommonShared.projitems*{0e1864bd-c462-4600-9c29-06bf8562a9b2}*SharedItemsImports = 13
CommonShared\CommonShared.projitems*{4827c16d-5c58-406d-ab3f-3700bb0d06fe}*SharedItemsImports = 4
Cli-Shared\Cli-Shared.projitems*{62f52119-63d4-40a8-a9df-f1c4b473308a}*SharedItemsImports = 4
CommonShared\CommonShared.projitems*{62f52119-63d4-40a8-a9df-f1c4b473308a}*SharedItemsImports = 4
CommonShared\CommonShared.projitems*{c1daabc1-b493-459d-bb4f-04fbefb1ba13}*SharedItemsImports = 4
CommonShared\CommonShared.projitems*{cf306116-bbf0-4cc7-afce-a506ac4752cb}*SharedItemsImports = 4
Cli-Shared\Cli-Shared.projitems*{dbd202c3-94d5-49d3-8ed1-c72637ba7d90}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution

140
README.md
Просмотреть файл

@ -1,139 +1,63 @@
# Git Credential Manager for Windows [![Build status](https://ci.appveyor.com/api/projects/status/jl6oe1thiwv5s52o/branch/master?svg=true)](https://ci.appveyor.com/project/whoisj/git-credential-manager-for-windows/branch/master)
The [Git Credential Manager for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows) (GCM) provides secure Git credential storage for Windows. It's the successor to the [Windows Credential Store for Git](https://gitcredentialstore.codeplex.com/) (git-credential-winstore), which is no longer maintained. Compared to Git's built-in credential storage for Windows ([wincred](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage)), which provides single-factor authentication support working on any HTTP enabled Git repository, GCM provides multi-factor authentication support for [Visual Studio Team Services](https://www.visualstudio.com/), [Team Foundation Server](#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs), and GitHub.
The [Git Credential Manager for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows) (GCM) provides secure Git credential storage for Windows. It's the successor to the [Windows Credential Store for Git](https://gitcredentialstore.codeplex.com/) (git-credential-winstore), which is no longer maintained. Compared to Git's built-in credential storage for Windows ([wincred](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage)), which provides single-factor authentication support working on any HTTP enabled Git repository, GCM provides multi-factor authentication support for [Visual Studio Team Services](https://www.visualstudio.com/), [Team Foundation Server](#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs), and GitHub.
This project includes:
This project includes:
* Secure password storage in the Windows Credential Store
* Multi-factor authentication support for Visual Studio Team Services
* Two-factor authentication support for GitHub
* Personal Access Token generation and usage support for Visual Studio Team Services and GitHub
* Non-interactive mode support for Visual Studio Team Services backed by Azure Directory
* Kerberos authentication for Team Foundation Server ([see notes](#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs))
* Optional settings for build agent optimization
* Secure password storage in the Windows Credential Store
* Multi-factor authentication support for Visual Studio Team Services
* Two-factor authentication support for GitHub
* Personal Access Token generation and usage support for Visual Studio Team Services and GitHub
* Non-interactive mode support for Visual Studio Team Services backed by Azure Directory
* Kerberos authentication for Team Foundation Server ([see notes](#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs))
* Optional settings for [build agent optimization](Docs/Automation.md)
This is a community project so feel free to contribute ideas, submit bugs, fix bugs, or code new features. For detailed information on how the GCM works go to the [wiki](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/wiki/How-the-Git-Credential-Managers-works).
### Community
This is a community project so feel free to contribute ideas, submit bugs, fix bugs, or code new features. For detailed information on how the GCM works go to the [wiki](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/wiki/How-the-Git-Credential-Managers-works).
## Download and Install
To use the GCM, you can download the [latest installer](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/latest). To install, double-click Setup.exe and follow the instructions presented.
To use the GCM, you can download the [latest installer](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/latest). To install, double-click Setup.exe and follow the instructions presented.
When prompted to select your terminal emulator for Git Bash you should choose the Windows' default console window. GCM cannot prompt you for credentials in a MinTTY setup.
When prompted to select your terminal emulator for Git Bash you should choose the Windows' default console window, or make sure GCM is [configured to use modal dialogs](Docs/Configuration.md#modalprompt). GCM cannot prompt you for credentials, at the console, in a MinTTY setup.
## How to use
You don't. It [magically](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/31) works when credentials are needed. For example, when pushing to [Visual Studio Team Services](https://www.visualstudio.com), it automatically opens a window and initializes an oauth2 flow to get your token.
You don't. It [magically](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/31) works when credentials are needed. For example, when pushing to [Visual Studio Team Services](https://www.visualstudio.com), it automatically opens a window and initializes an oauth2 flow to get your token.
### Manual Installation
Note for users with special installation needs, you can still extract the `gcm-<version>.zip` file and run install.cmd from an administrator command prompt. This allows specification of the installation options explained below.
Note for users with special installation needs, you can still extract the `gcm-<version>.zip` file and run install.cmd from an administrator command prompt. This allows specification of the installation options explained below.
### Build and Install from Sources
To build and install the GCM yourself, clone the sources, open the solution file in Visual Studio, and build the solution. All necessary components will be copied from the build output locations into a `.\Deploy` folder at the root of the solution. From an elevated command prompt in the `.\Deploy` folder issue the following command `git-credential-manager install`.
To build and install the GCM yourself, clone the sources, open the solution file in Visual Studio, and build the solution. All necessary components will be copied from the build output locations into a `.\Deploy` folder at the root of the solution. From an elevated command prompt in the `.\Deploy` folder issue the following command `git-credential-manager install`. Additional information about [development and debugging](Docs/Development.md) are available in our documents area.
Various options are available for uniquely configured systems, like automated build systems. For systems with a **non-standard placement of Git** use the `--path <git>` parameter to supply where Git is located and thus where the GCM should be deployed to. For systems looking to **avoid checking for the Microsoft .NET Framework** and other similar prerequisites use the `--force` option. For systems looking for **silent installation without any prompts**, use the `--passive` option.
[Various options](Docs/Configuration.md) are available for uniquely configured systems, like automated build systems. For systems with a **non-standard placement of Git** use the `--path <git>` parameter to supply where Git is located and thus where the GCM should be deployed to. For systems looking to **avoid checking for the Microsoft .NET Framework** and other similar prerequisites use the `--force` option. For systems looking for **silent installation without any prompts**, use the `--passive` option.
## FAQ
### Additional Resources
Frequently asked questions collected from our [issues page](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues), our [Twitter feed](https://twitter.com/microsoftgit), and other sources. Please look through this list of questions-and-answers before posting a new issue on a topic.
### Q: Why am always prompted for my username and password?
Most likely, your environment is not configured correctly. You can verify that your environment is configured correctly by running `git config --list` and looking for `credential.helper=manager`. If you do not see the line, then you know that Git does not know about the Git Credential Manager. You can configure Git to use the Credential Manager by running `git config credential.helper manager`.
### Q: Why does my GUI freeze when I push, pull, or fetch?
Most likely reason is that your GUI “shells out” to git.exe to perform Git operations. When it does so, it cannot respond to the command line prompts for username and password like a real user can. To avoid being asked for your credentials on the command line, and instead be asked via a modal dialog youll need to configure the Credential Manager.
1. Decide if you want this to be a global setting (all of your repositories) or a local setting (just one repository).
2. Start your favorite shell. (cmd, powershell, bash, etc.)
3. Update your settings, so that Git Credential Manager knows to display a dialog and not prompt at the command line:
* If youve decided this is a global setting run `git config --global credential.modalprompt true`.
* If youve decided this a per repository setting, `cd` to your repo and in that repo run `git config credential.modalprompt true`.
### Q: Why am I not seeing my SSH keys being saved?
The Git Credential Manager does not *yet* support secure storage for SSH keys. It is something we hope to implement, but it has not been a priority. If you feel otherwise, please comment on the [SSH Key support issue](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/25) which is already open.
### Q: Is there a NuGet Package available?
Yes there is: <https://www.nuget.org/packages/Microsoft.Alm.Authentication>. It only supports the core authentication library, but if you're looking to extend the GCM then it is likely exactly what you're after.
### Q: Why doesnt Git Credential Manager work on Windows XP, Mac OS, or Linux?
The Git Credential Manager does not work on Windows XP, Max OS, or Linux because we had to scope our work and we decided to support the same operating systems that Visual Studio support. Why Visual Studio? Well, because it is our favorite IDE and in order to support [Visual Studio Team Services](https://www.visualstudio.com/en-us/products/visual-studio-team-services-vs.aspx) we had to use the [Azure Directory Authentication Libraries](https://github.com/AzureAD) which only have multi-factor interactive logon support in their .NET libraries. Using .NET means using Visual Studio (which we love anyways) and using Visual Studio means Windows 7 or newer.
### Q: Will there ever be support for Windows XP, Mac OS, or Linux?
We can safely say that we have no interest in supporting Windows XP. Even [Microsoft has ended support for Windows XP](https://windows.microsoft.com/en-us/windows/end-support-help). Support for Mac OS and Linux are handled by [Microsoft Git Credential Manager for Mac and Linux](https://github.com/Microsoft/Git-Credential-Manager-for-Mac-and-Linux).
### Q: Why is my distribution/version of Git not supported? Why is Git for Windows favored?
The Credential Manager deployment helpers (`install.cmd` and `Setup.exe`) are focused on support for [Git for Windows](https://github.com/git-for-windows) because Git for Windows conforms to the expected/normal behavior of software on Windows. It is easy to detect, has predictable installation location, etc. This makes supporting it cheaper and more reliable.
That said, so long as your favorite version of Git supports Gits git-credential flow, it is supported by the Git Credential Manager for Windows. Setup will have to be manual, and if you find a way to script it we would love to have you contribute that to our project.
1. Copy the contents of the `gcm-<version>.zip` to your Gits /bin folder. This varies per distribution, but it is likely next to other git tools like `git-status.exe`.
2. Update your Git configuration by running `git config --global credential.helper manager`.
### Q: I thought Microsoft was maintaining this, why does the GCM not work as expected with TFS?
Team Foundation Server, when deployed on a corporate Active Directory, uses the [Microsoft Kerberos](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378747(v=vs.85).aspx) protocol for authentication. Git doesn't "speak" the Kerberos protocol.
Git can be convinced to "forward" domain credentials by supplying a blank credentials (username and password). Since, by default, the GCM doesn't allow for a blank credentials, you will need to configure it to allow for them. To do so, update your Git configuration by running `git config --global credential.tfs.fabrikam.com.integrated true`.
Once updated, the new configuration tells the GCM to only forward domain credentials. If you set `credential.integrated true`, every domain will be assumed to support domain credentials. Most likely, this is **not** what you want. Therefore, it strongly suggested that you restrict the configuration setting to the URL of your TFS Git host.
### Q: Why doesn't SourceTree use the credentials in the GCM?
You need to configure SourceTree to use the version of Git installed for the entire system. By default, SourceTree uses a local copy of portable Git.
To fix this go to Tools -> Options -> Git and click the "Use System Git" button. This works in v1.8.3.0 of SourceTree.
## Build agents
Build agents cannot manage modal dialogs, therefore we recommended the following configuration.
```
git config --global credential.interactive never
```
Build agents often need to minimize the amount of network traffic they generate.
To avoid Microsoft Account vs. Azure Active Directory look-up against a Visual Studio Team Services account use:
```
git config --global credential.authority Azure
```
To avoid unnecessary service account credential validation use:
```
git config --global credential.validate false
```
* [Credential Manager Usage](Docs/CredentialManager.md)
* [Askpass Usage](Docs/Askpass.md)
* [Configuration Options](Docs/Configuration.md)
* [Build Agent and Automation Support](Docs/Automation.md)
* [Frequently Asked Questions](Docs/Faq.md)
* [Development and Debugging](Docs/Development.md)
## Contribute
There are many ways to contribute.
There are many ways to contribute.
* [Submit bugs](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues) and help us verify fixes as they are checked in.
* Review [code changes](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/pulls).
* Contribute bug fixes and features.
* [Submit bugs](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues) and help us verify fixes as they are checked in.
* Review [code changes](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/pulls).
* Contribute bug fixes and features.
For code contributions, you will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you grant us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under the appropriate copyright.
### Code Contributions
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit <https://cla.microsoft.com> to sign digitally. Alternatively, download the agreement [Microsoft Contribution License Agreement.pdf](https://cla.microsoft.com/cladoc/microsoft-contribution-license-agreement.pdf), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your GitHub user name along with the agreement. Once we have received the signed CLA, we'll review the request.
For code contributions, you will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you grant us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under the appropriate copyright.
## Debugging
To enable logging, use the following:
```
git config --global credential.writelog true
```
Log files will be written to the repo's local `.git/` folder.
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit <https://cla.microsoft.com> to sign digitally. Alternatively, download the agreement [Microsoft Contribution License Agreement.pdf](https://cla.microsoft.com/cladoc/microsoft-contribution-license-agreement.pdf), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your GitHub user name along with the agreement. Once we have received the signed CLA, we'll review the request.
## Code of Conduct

Просмотреть файл

@ -41,7 +41,7 @@
#define NetFxSpace 381005824
[Setup]
AppId={{9F0CBE43-690B-4C03-8845-6AC2CDB29815}
AppId={{9F0CBE43-690B-4C03-8845-6AC2CDB29815}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
@ -90,6 +90,8 @@ Source: "{#deployDir}\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"; Dest
Source: "{#deployDir}\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#deployDir}\GitHub.Authentication.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#deployDir}\README.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#deployDir}\git-credential-manager.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#deployDir}\git-askpass.html"; DestDir: "{app}"; Flags: ignoreversion
[Code]
type NetFx_Version = (