Skip to content

Instantly share code, notes, and snippets.

@Boggin
Last active October 14, 2020 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Boggin/6494103bd5c685df756c to your computer and use it in GitHub Desktop.
Save Boggin/6494103bd5c685df756c to your computer and use it in GitHub Desktop.
Git Tfs : HowTo

Git Tfs

If you would like to use git locally against the TFS repositories you can use git-tfs.

You can install git from the Windows installer: http://git-scm.com/downloads.
I prefer to install the bash command line and all the Unix tools. You may still prefer to use the GUI which is installed at the same time.

Then you can install git-tfs via chocolatey.
Note: If you don't have chocolatey goodness yet then see the Chocolatey Install section below.

PS > cinst GitTfs

To clone the root repositories you should create and then change into a top level directory in the newly installed Git Bash shell.

$ cd /C/Source

Note: I recommend C:\Source to keep the path names shorter as there's a character limit that's all too easily hit with source code hierarchies.

Now you can clone the whole of Guided Outcomes with all of the commit history (this will take a wee while).

$ git-tfs clone http://hrglatfs02:8080/tfs/GO/ $/Guided\ Outcomes

I got the URL to clone from by looking at the TFS Portal (Team Explorer > Web Portal).

Usage

Update your ~/.gitconfig with the following aliases:

[alias]
    tpull = "!git-tfs fetch && git rebase tfs/default"
    tpush = "!git-tfs checkintool"

This will let you pull with git tpull and check-in with git tpush.

Chocolatey Install

You can install chocolatey from PowerShell with the following:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted;$a=new-object net.webclient;$a.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials;$a.downloadstring('https://chocolatey.org/install.ps1')|iex

Proxy Authentication

Git is terribly useful for pulling in source from on-line repo's like GitHub but it can't do NTLM authentication against a Windows proxy, which is required here. You may need to install and configure CNTLM as this provides a local authenticating proxy. Here's a walk-through.

  • The cntlm.exe has been renamed to something else as some policies won’t allow it to be installed. How about mostly_harmless.exe? :)
    S:\GO shared Folder\Developer Setup\mostly_harmless.7z
    Unpack this into your %programfiles(x86)% folder.
  • Use the command line options -H -u -d to get the hashes for your mostly_harmless.ini config file:
    mostly_harmless.exe -H -u [username] -d hymans
    Enter your password when required and your hashes will be produced.
  • Edit mostly_harmless.ini and set the Username [username] and PassNTLMv2 [password] fields.
    The PassNTLMv2 is the hash that was generated in the previous step, not your password.
  • Launch the application:
    mostly_harmless.exe -c mostly_harmless.ini
  • Edit your .gitconfig:
    [http] proxy=http://127.0.0.1:3128
    [https] proxy=http://127.0.0.1:3128

Git can now work through the transparent authenticating proxy on your machine to the company's proxy.

You can create a .bat file for your Startup folder to set the mostly_harmless process running:

cd %PROGRAMFILES(X86)%\mostly_harmless
mostly_harmless.exe -c mostly_harmless.ini

Note: CNTLM can be used for tunnelling which is why some policies prevent its installation. Don't use it for tunnelling through the firewall, please, as it's against the company policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment