14 August 2016

gitk on Bash on Ubuntu on Windows 10You may have heard about “Bash on Ubuntu on Windows”. If not, you can check out my post on Bash for Windows 10.

First, you’ll need to make sure you have the Windows 10 Anniversary Update, which you’ve probably received automagically by now.

Then, you’ll need to manually install Bash on Ubuntu on Windows to get your bash prompt.

When you’re done, you’ll probably listen to Microsoft when they say “no GUI stuff!” on bash… But actually, you can set yourself up with a lovely development environment including git – and even gitk – right in Windows.

And it’s much easier than you might think…

Install Bash on Ubuntu on Windows

Okay, the first step is to install Bash on Ubuntu on Windows, which I shall henceforth refer to as BUW – pronounced, “BOO!”

As in, “Holy crap! I’m frightened by the fact that Microsoft actually included linux in Windows, because it probably means the world will end in 3 days!”

Anyway, do this:

  1. Click Start
  2. Click Settings
  3. Click Update & security
  4. Click For developers in the left pane
  5. Click Developer mode

You’ll see something like this:

User developer features in Windows 10
As you can see, Windows 10 will install the “Developer Mode package”.

When it’s done, you’ll have a new “Bash” program in your Start Menu, but with a generic app icon. The next step is to click Start, and then run Bash.

In the lovely command prompt that pops up, you’ll be asked to install “Ubuntu on Windows”. Press Y.

Installing Ubuntu on Windows
When that’s done, you can click Start again, and then click Bash on Ubuntu on Windows – which has now changed to the pretty orange Ubuntu logo.

Ta-DA! You now have Bash on Ubuntu on Windows.

IMPORTANT: Right-click your Bash on Ubuntu on Windows icon on the desktop or taskbar, choose Properties, and set it to Run as administrator. If you don’t, things like ping won’t work in Bash!

Install git

This part is pretty easy. Since BUW is just an Ubuntu shell running in a sort of “reverse-WINE” on top of Windows, you just install stuff like you normally would in Ubuntu linux. For example:

  1. sudo apt-get update
  2. sudo apt-get install git

Wasn’t that easy?

You can now configure git and use it as you would on a dedicated linux box, or via VirtualBox or VMware.

Note that your local Windows hard drives are accessible at the following paths in Bash:

  • /mnt/c/
  • /mnt/d/
  • etc.

Install gitk – for that graphical touch

So, you’re pretty happy. You can grab a git repo, edit the files locally in Windows or with vi in Bash, and then push your changes using git in Bash. It’s all seamless and glorious, and no more bloated nasty ultra-fancy Git for Windows nonsense…

BUT, it would be really nice to have gitk, don’tcha think?

Well, despite Microsoft’s claims that BUW doesn’t support running graphical apps in separate windows, you can do this very easily.

  1. In Bash: sudo apt-get install gitk
  2. Download the Xming X Server for Windows
  3. Install Xming. The default settings should work just fine.
  4. Run Xming, preferably as an administrator

Congratulations! You now have a lightweight X Window Server on your Windows 10 box. All that’s left is to tell BUW where to find the X Server so linux apps can draw pretty windows with a GUI and everything:

  1. pico ~/.bashrc (or if you prefer, vi ~/.bashrc)
  2. At the very end of .bashrc, add this line: export DISPLAY=:0
  3. Save!
  4. Either close and restart Bash, or run the same export command at the shell prompt to set the DISPLAY variable for your current session.

Now, just type gitk in your Bash window:

gitk on Bash on Ubuntu on Windows 10

git + gitk on Bash on Ubuntu on Windows… on Land on Country on Earth on Space on Universe!

Note that this little “trick” also seems to work well for other graphical linux apps. For example, you could install Firefox in BUW, and run it.

Poof! Linux Firefox running via Xming on your Windows 10 desktop!

Pretty sassy, eh?

It broke!

Well, yeah… Bash on Ubuntu on Windows is still beta.

But so far, I’ve been using it since its release, and it’s pretty darn stable on my end.

Auto-updates?

Finally, be aware that after you install BUW, you may occasionally see a Bash window pop up and run updates out of the blue.

Apparently, Windows Update also automagically invokes Bash updates to keep BUW up to date for you.

I’m not totally sure what it’s doing since it ran so fast that I didn’t have time to read anything, but it looked like an apt-get upgrade.

Which is even MORE sassy…

How to install git and gitk on Bash on Ubuntu on Windows 10
Tagged on:                     

Leave a Reply

Your email address will not be published. Required fields are marked *