How to install git and gitk on Bash on Ubuntu on Windows 10
You 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:
- Click Start
- Click Settings
- Click Update & security
- Click For developers in the left pane
- Click Developer mode
You’ll see something like this:
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.
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!
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:
- sudo apt-get update
- 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:
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.
- In Bash: sudo apt-get install gitk
- Download the Xming X Server for Windows
- Install Xming. The default settings should work just fine.
- 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:
- pico ~/.bashrc (or if you prefer, vi ~/.bashrc)
- At the very end of .bashrc, add this line: export DISPLAY=:0
- 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:
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?
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.
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…