Skip to content

Instantly share code, notes, and snippets.

@elisee
Last active May 31, 2024 16:06
Show Gist options
  • Save elisee/310ecdb6899d8d9ff1d64fdf7b77dcd0 to your computer and use it in GitHub Desktop.
Save elisee/310ecdb6899d8d9ff1d64fdf7b77dcd0 to your computer and use it in GitHub Desktop.
Nice Git experience on Windows

Install latest Git (main tool)

From https://git-scm.com/download/win

  • Select Components: Uncheck "Windows Explorer integration", it adds context menu options everywhere that aren't useful.
  • Choosing the default editor used by Git: "Use Visual Studio Code as Git's default editor"
  • Choose the default behavior of git pull: I recommend "Only ever fast-forward" so you never end up merging unknowingly

Install P4Merge (diff tool)

It's a clean and functional 2-way and 3-way diff tool, much better than any alternative I've seen.

From https://www.perforce.com/downloads/visual-merge-tool.

When running the installer, make sure to uncheck everything but "Merge and Diff Tool (P4Merge)". We don't need the rest.

Install latest Git Extensions

Git Extensions is a fully-fledged GUI for Git.

Grab GitExtensions-....msi from https://github.com/gitextensions/gitextensions/releases/latest

Make sure to select PuTTY (plink.exe) rather than OpenSSH as SSH Client during the installation. PuTTY lets you load and manage private keys easily on Windows.

Configuration

  • After launching Git Extensions, make sure to select p4merge as both your merge & diff tools.
  • Do use Checkout Windows-style, commit Unix-style ("core.autocrlf" is set to "true"). It works and you won't fight with any tools on Windows.

Why this setup

Git Extensions is very stable and it has all the features you need to really deeply manage your repository. Commandline is fine if you like it, but I think there's a lot of value in doing those operations with clear visualization of the commits and branches involved at all time.

It supports all the basics plus interactive rebasing (launches a tiny text editor to squash / fixup / reword / drop commits), cherry picking, staging only some lines, amending, etc.

If you don't know what those operations are or aren't very comfortable with them, I heartily recommend you just clone a real repo with a bunch of commits, try interactive rebase (it's a checkbox you need to tick in the rebase popup) and drop, reorder, squash commits together, reword them, etc.

Don't let Git be a scary beast, it really doesn't have to be, it's just another tool in your belt.

(Difference between fixup and squash: fixup will combine two commits and keep only the first commit's message. squash will add all the messages together and let you edit the resulting combined message. That's it.)

By the way you can never really lose commits. Use "Repository -> Git maintenance -> Recover lost objects...". All your recent commits that might have been dropped from existing branches are right there and can be made visible again in a couple of clicks.

Even just for committing, using Git Extensions gives a lot of flexibility so you can see and act on your index and staging area fast & confidently. You can select a line and press S to stage it, U to unstage it, R to revert.

(Its counterpart for Mercurial is TortoiseHg. I used to praise Mercurial, now that I found Git Extensions, I'm all in on Git.)

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