Skip to content

Instantly share code, notes, and snippets.

@dotnetchris
Forked from dmangiarelli/GitForWindowsSetup.md
Last active December 22, 2022 22:23
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 dotnetchris/a40e02f98754a8cacd4f3b8679ce159d to your computer and use it in GitHub Desktop.
Save dotnetchris/a40e02f98754a8cacd4f3b8679ce159d to your computer and use it in GitHub Desktop.
How to setup Git for Windows

How to setup Git for Windows

Improve developer's experience inside powershell, adding useful commands like Add-PathVariable. This is optional but recommended to minimize confirmation of every single action you invoke.

First let's update powershell itself (elevated):

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

Elevated powershell:

Set-PSRepository -Name PsGallery -InstallationPolicy Trusted

Install-Module Pscx -Scope CurrentUser -AllowClobber #Add-PathVariable and other helpful cmdlets
Install-Module Carbon -AllowClobber

Set-ExecutionPolicy RemoteSigned

Import-Module Carbon

Update-Help

You could set Unrestricted for policy level, however according to discussions it will likely not last long. https://stackoverflow.com/a/34889926

Git

Download and run the latest Git for Windows installer https://git-scm.com/download/win which includes Git Credential Manager Core. Make sure to enable the Git Credential Manager installation option.

UNTESTED, next build out I'm going to try to run GitHub CLI and hopefully no other git stuff other than GitEx for it's gui's.

Chocolately

Package management system, like apt-get for windows. Everything will use this.

Note, you may wish to ensure a powershell profile exists. This command will not overwrite any file if it exists already.

New-Item -itemType File -Path $env:USERPROFILE\Documents\WindowsPowerShell -Name Microsoft.PowerShell_profile.ps1

Critical ensure powershell is running admistrator

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

choco feature enable -n allowGlobalConfirmation

refreshenv

The Global Confirmation feature is optional but recommended, once again to limit the amount of confirmations to actions you invoke.

refreshenv is a cmdlet provided by chocolately to avoid needing to close and reopen the terminal for environment variable changes (like the path variable). This command does not work on Windows Server installations.

Windows Terminal

I still install Cmder (at this point, primarily for mintty) but now I almost solely use Windows Terminal.

I run Windows Terminal Preview installed right from the app store. You can alternatively install the GA

There is support for a bunch of color schemes: https://windowsterminalthemes.dev/

Cmder

Optional if you install Windows Terminal. Cmder is one of the most useful extensions for running terminal windows in Windows. You can run cmd, powershell, bash, and even mintty terminals all side by side.

Critical ensure powershell is running admistrator

choco install cmder

If you want machine wide cmder access

Add-PathVariable "C:\tools\cmder" -Target Machine

Add-PathVariable "C:\tools\cmder" -Target Process

refreshenv

cmder

Open Settings, click Startup (tree menu header item itself), select Auto save/restore opened tabs [todo add picture]

Some additional stand alone tools

choco install sharex

choco install 7zip

choco install notepadplusplus
choco install notepadplusplus-npppluginmanager

choco install jq

choco install wget

choco install aria2

choco install sql-server-management-studio

choco install dbeaver

choco install sysinternals

choco install bloomrpc

choco install docker
choco install docker-desktop

ShareX

  • review upload settings under 'After capture tasks' flyout navigation on screen app menu
  • review Application Settings - Advanced tab - Upload section - Disable Upload key and others

Notepad++

7zip

  • review file assocation settings Tools < options

JQ

Wget

Aria2

  • cli downloader, including torrents https://aria2.github.io/
    • aria2c http://releases.ubuntu.com/16.04/ubuntu-16.04.7-server-amd64.iso.torrent
    • Certify download matches published hashes certutil -hashfile ubuntu-16.04.7-server-amd64.iso SHA256

SSMS

  • Best sql editor

DBeaver

SysInternals

BloomRPC

Docker

  • Commandline and windows

Git

Git uses a per-user config file located at %USERPROFILE%\.gitconfig. It's a plain-text file you can edit with your favorite text editor (or Notepad, if you haven't chosen a favorite yet). Note that git calls this config the "global" config. It's more general than per-repository config, and more specific than the machine config.

TortoiseGit

Download and install TortoiseGit.

Chocolatey:

choco install tortoisegit

posh-git

  1. Make sure you have PowerShell 5 or later installed.
    To check, open PowerShell from your Start menu/screen and type $PSVersionTable. The PSVersion value should be 5.0 or greater.
    If you don't have v5 or later installed, download and run the correct installer for Windows Management Framework 5 (which comes with PowerShell 5) from this page.
  2. Change PowerShell's script execution policy.
    Open an elevated PowerShell prompt and enter:
    Set-ExecutionPolicy RemoteSigned
  3. Install Posh-Git.
    Install-Module Posh-Git

Now, whenever you're in a Git workspace directory in your PowerShell prompt, you'll get a fancy prompt, and you can still use tab completion and standard Windows paths. Hooray! Git will still echo paths with backslashes, but it will recognize forward slashes.

Other Tools

  • Git Extensions is another shell extension that also has a Visual Studio extension. It's very user-friendly.

Elevated powershell:

choco install gitextensions
Add-PathVariable "C:\Program Files (x86)\GitExtensions" -Target Machine
choco install kdiff3
refreshenv
  • GitHub Desktop, not to be confused with Git for Windows, is GitHub's Windows Git client.
  • SourceTree is to Bitbucket as GitHub for Windows is to GitHub: it's Atlassian's answer to GitHub for Windows.

Setup aliases

git config --global alias.co checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment