Unix and Git
Apr 16, 2016 at NYχ

I gave this talk, in two parts, at NYchi, the New York Capital Hack-a-thon for Inclusivity.




Part 1 (Introduction)

Just getting started with programming? Want to get involved with an open source project? You need to know your way around the command line!

This foundational talk will show you how to access the command line (or install a Unix-like command line tool if you are on a Windows machine). We will discuss the basic bash commands for moving through the file system, creating directories, and accessing remote machines. You’ll even learn how to customize your environment!

During the second half of this talk will be all about Git: the hottest version tracker around! This talk will review the basics of version tracking, including a best practices. You will then have a chance to work with Git on your own and install it to your machine. By the end, you’ll set up your own GitHub account and be ready to start hacking!

Part 2 (Intermediate)

So you know how to navigate with the terminal and you can commit your coding changes… now what? This talk tackles the more advance topics and picks up right where Part 1 left off.

We will discuss shell scripting, alternate shells (such as fish and zsh), and using the built in editors. You’ll also learn the best aliases, package managers, and third party tools (and how to make your case against opinionated colleagues). By the end you’ll be a true power user!

During the second half of the talk we will review Git and describe the nitty-gritty of how it works. You’ll learn how to setup your own Git server and have a chance to work with Git branches and the cherry-pick command. We will also touch on other version tracking tools and how to convince your manager or adviser to switch to Git!

Useful Links

Useful Links

Link Description
Babun Unix shell on Windows
Try Git Interactive basic Git commands, from GitHub
GitHub GitHub: social coding and free hosting for open source software
GitHub for Education Access to the Student Developer
Advanced Git Commands Interactive Advanced Git: branching & more
Homebrew Package manager for Mac
Gonsie’s Dot Files You’ve seen it live, now try it for yourself
Unix and the Command Line

Unix and the Command Line

Understanding and using the command line is a key skill for any computer user. The command line interface (CLI)1 is the original way in which humans interacted with computers. This interaction is done through the shell. It is no longer necessary to use computers in this way since most tasks can be accomplished through the GUI2. Nevertheless, the command line interface remains the most common, easiest to use, and best supported way in which expericenced users accomplish daily tasks.


In general the Mac OS is a Unix operating system, one that is very similar to Linux operating systems. Windows, on the other hand, is a DOS-based operating system which is very different from -nix. For any of these systems, there is a built-in application for the interacting with your computer via a CLI.

Mac Installation

You’re in luck! Since Mac OS is based upon Unix, there is nothing for you install. To access the command line interface, simply run the Terminal application. The Terminal application can be found in the Utilities folder inside the Application folder.

Linux Installation

Just like a Mac, you are working with a -nix based system and there is nothing new to install! To access the command line interface, simply run the Terminal application. The Terminal application can most likely be found where ever your other Applications exist.

Windows Installation

Since Windows is not a -nix-based operating system, the command line interface that comes with your machince is vastly different from a -nix shell. For your own information, the Windows CLI is called PowerShell. For this workshop you will need to install a -nix-like interface for your computer.

Step 1: Install Babun

Babun is an open source project which brings the Unix command line to your Windows machine.

Download Babun Here: http://projects.reficio.org/babun/download.

This project is built on top of the popular Cygwin project. If you already have Cygwin installed, it is not necessary to install Babun, but you can. The two projects will not clash.

Step 2: ???

As you may have noticed, I do not have a Windows machine. Thus, I do not know what step 2 is. You probably need to run an installer? See what happens and, if you want, let me know the important steps so I can share those with others.

Commands on the Command Line

Welcome to the command line interface! You are probably staring a big blank box with some text in the upper left corner, maybe something like:

MyMacBook:~ elsa$

Hit the Enter or return key. You should see the same text appear over and over. This text is called the prompt. It is very common to have $ or > symbol at the end of your prompt text, indicating where you will enter commands.


Command Arugment Option Argument for Option Another Option
g++ main.cpp -o main.out -W

Commands take arguments and have options. One-letter options usually start with a single dash (-) while multi-letter options start with two dashes (--). Options may also take an argument.

Bread-and-Butter Commands

Example Usage Description
ls ~/Desktop list files (on the desktop)
pwd present working directory, or, where am I?
cd ~/Desktop change directory (to the desktop)
mkdir FOLDER make a directory (called FOLDER)
cat notes.txt concatenate the contents (of notes.txt) to the terminal
echo "hello" repeat after me
cp notes.txt notes-copy.txt make a copy (of notes.txt to new file notes-copy.txt)
mv notes-copy.txt tmp.txt move the file (renames notes-copy.txt to tmp.txt)
man git read the man pages (about the git command)
rm notes.txt remove (the notes.txt file)

Learning More About Commands

Almost all commands come with either a -h or --help option. Sometimes, the text is more detailed in the “longer” --help option. The manual for each command, called the man pages, are also installed. These are accessed by the command man.

Try it!

Get to know the commands on your own by trying to accomplish the following tasks:

Filenames and Paths

A file system is different from the operating system. This is an important distinction when we are working with files.



As you may have seen through the ls command, there are several hidden files in your file system. These filenames usually begin with a dot (.), such as .gitconfig or .gitignore. To list all files in a directory, including the hidden files, use ls -A.

Dotfiles usually hold the settings for the command line tools you use. This includes color settings, command shortcuts, environment variables, load packages, and more!


Since dotfiles customize how you interact with the command line, many people have shared their personal dotfiles through GitHub. By browsing the dotfiles repositories, you can find new tricks that will make your life easier!


The .inputrc file works with the bash shell (and others) to customize how you interact with the command line itself. I find the following settings to be essential on any shell that I use:

Simply place the following in a .inputrc file in your home directory:

"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on



Bash: Bourne Again Shell1

Bash is the default shell on most Linux and Unix systems (including Mac OS).

Fish: Friendly Interactive Shell

Fish is a modern shell, currently under active development. It has many modern convinces:

Once you are familiar with Bash and other basics of Unix-Shells, try fish!

Zsh: Z Shell

Zsh is based on bash and other shells including ksh and tcsh (there are a lot of shells). Similar to fish, zsh is an interactive shell and it has powerful auto suggestions and auto completions. Many people who use zsh also make use of oh-my-zsh, a manager for zsh plugins, themes, and configurations.



Git is a program for version tracking. It tracks the changes that you (and others) make to files within a repository.

Installing Git

The installation step for any software package or application depends on the machine where it is being installed1. The “official” instructions for installing Git on your system can be found here.

To test if you have git installed, type the git command into your terminal. If you do have git installed, you will see a long messages describing how to use the git program. The message starts with:

usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

Mac Installation

If you tried the git command in your terminal and you do not have git installed on you system, a message will display with details about how to install it.

Linux Installation

If you are running a Linux machine, you should open your Terminal application and install git through your package manager.

On a Fedora system the command is:

$ sudo yum install git-all

On a Debian-based system, such as Ubuntu, the command should be:

$ sudo apt-get install git-all

Windows Installation

If you used the instructions above to install Babun, you are all set! If you would like to install git at a system-level, follow the “official” instructions.

Command Line Git

Git, as a command line tool, is a program which takes its own set of commands.

Man Pages

The git program on your computer which takes it own set of commands. Thus, man git may not contain useful information about a particular git command. Instead, you can lookup man git-init or man git-pull.

Setting Up Your Computer

When you make a commit, some additional information is automatically recorded, including:

To configure the global git settings for your computer, type the following:

$ git config --global user.name "My Full Name"
$ git config --global user.email myemail@domain.com

Git GUIs

I believe that learning git on the command line

Now that you know the basics of the git commands, you can understand what the GUI’s are doing for you.

  1. Requiring machine-specific installation instructions can be a pain for programmers. Recently, programmers have been able to take advantage operating-system-level virtualizations called containers, such as Docker. Containers serve as way to specify the dependencies of a certain piece of software and abstract the need to specify the underlying hardware. 



GitHub.com has become the place for sharing code and hosting open source software projects. Employers have started asking for GitHub usernames when recruiting new employees.

Like any social platform, you can follow your favorite users and star your favorite repositories.

Try Git

If you want to get some more experience with git, use GitHub’s interactive Try Git demo.


GitHub Pages are an easy way to create and host a website. GitHub lets you create a website for each user and repository.

GitHub supports static sites generated with Jekyll. Static sites (as opposed to dynamic sites) are usually simple, text-based websites that do not require databases or other advanced/backend features.


If you have a .edu email address, you can take advantage of the GitHub for Education program. This program includes the Student Developer Pack, with discounts on many software packages and cloud services. Some of the best discounts include:


GitHub Desktop is a GUI interface for git which automatically connects to GitHub.com.