Once you have Git and Bash installed, you are ready to configure Git.
On this page you will:
- Create a directory for all future GitHub repositories created on your computer
To ensure Git is properly installed and to create a working directory for GitHub, you will need to know a bit of shell -- brief crash course below.
Crash Course on Shell
The Unix shell has been around longer than most of its users have been alive. It has survived so long because it’s a power tool that allows people to do complex things with just a few keystrokes. More importantly, it helps them combine existing programs in new ways and automate repetitive tasks so they aren’t typing the same things over and over again. Use of the shell is fundamental to using a wide range of other powerful tools and computing resources (including “high-performance computing” supercomputers).
This section is an abbreviated form of Software Carpentry’s The Unix Shell for Novice’s workshop lesson series. Content and wording (including all the above) is heavily copied and credit is due to those creators (full author list).
Our goal with shell is to:
- Set up the directory where we will store all of the GitHub repositories during the Institute,
- Make sure Git is installed correctly, and
- Gain comfort using bash so that we can use it to work with Git & GitHub.
How one accesses the shell depends on the operating system being used.
- OS X: The bash program is called Terminal. You can search for it in Spotlight.
- Windows: Git Bash came with your download of Git for Windows. Search Git Bash.
- Linux: Default is usually bash, if not, type
bashin the terminal.
The dollar sign is a prompt, which shows us that the shell is waiting for input; your shell may use a different character as a prompt and may add information before the prompt.
When typing commands, either from these tutorials or from other sources, do not
type the prompt (
$), only the commands that follow it.
In these tutorials, subsequent lines that follow a prompt and do not start with
$ are the output of the command.
listing contents - ls
Next, let's find out where we are by running a command called
pwd -- print
working directory. At any moment, our current working directory is our
current default directory. I.e., the directory that the computer assumes we
want to run commands in unless we explicitly specify something else. Here, the
computer's response is
/Users/neon, which is NEON’s home directory:
$ pwd /Users/neon
If you are not, by default, in your home directory, you get there by typing:
$ cd ~
Now let's learn the command that will let us see the contents of our own
file system. We can see what's in our home directory by running
$ ls Applications Documents Library Music Public Desktop Downloads Movies Pictures
(Again, your results may be slightly different depending on your operating system and how you have customized your filesystem.)
ls prints the names of the files and directories in the current directory in
alphabetical order, arranged neatly into columns.
Change directory -- cd
Now we want to move into our Documents directory where we will create a
directory to host our GitHub repository (to be created in Week 2). The command
to change locations is
cd followed by a directory name if it is a
sub-directory in our current working directory or a file path if not.
cd stands for "change directory", which is a bit misleading: the command
doesn't change the directory, it changes the shell's idea of what directory we
To move to the Documents directory, we can use the following series of commands to get there:
$ cd Documents
These commands will move us from our home directory into our Documents
cd doesn't print anything, but if we run
pwd after it, we can
see that we are now in
If we run
ls now, it lists the contents of
that's where we now are:
$ pwd /Users/neon/Documents
$ ls data/ elements/ animals.txt planets.txt sunspot.txt
cd, you need to be familiar with paths, if not, read the section on
Full, Base, and Relative Paths .
Make a directory -- mkdir
Now we can create a new directory called
GitHub that will contain our GitHub
repositories when we create them later.
We can use the command
mkdir NAME-- “make directory”
$ mkdir GitHub
There is not output.
GitHub is a relative path (i.e., doesn't have a leading slash), the
new directory is created in the current working directory:
$ ls data/ elements/ GitHub/ animals.txt planets.txt sunspot.txt
Is Git Installed Correctly?
All of the above commands are bash commands, not Git specific commands. We still need to check to make sure git installed correctly. One of the easiest ways is to check to see which version of git we have installed.
Git commands start with
We can use
git --version to see which version of Git is installed
$ git --version git version 2.5.4 (Apple Git-61)
If you get a git version number, then Git is installed!
If you get an error, Git isn’t installed correctly. Reinstall and repeat.
Setup Git Global Configurations
Now that we know Git is correctly installed, we can get it set up to work with.
The text below is modified slightly from Software Carpentry's Setting up Git lesson.
When we use Git on a new computer for the first time, we need to configure a few things. Below are a few examples of configurations we will set as we get started with Git:
- our name and email address,
- to colorize our output,
- what our preferred text editor is,
- and that we want to use these settings globally (i.e. for every project)
On a command line, Git commands are written as
git verb, where
verb is what
we actually want to do.
Set up you own git with the following command, using your own information instead of NEON's.
$ git config --global user.name "NEON Science" $ git config --global user.email "neon@BattelleEcology.org" $ git config --global color.ui "auto"
Then set up your favorite text editor following this table:
|Sublime Text (Mac)||
|Sublime Text (Win, 32-bit install)||
|Sublime Text (Win, 64-bit install)||
The four commands we just ran above only need to be run once:
--global tells Git to use the settings for every project in your user
account on this computer.
You can check your settings at any time:
$ git config --list
You can change your configuration as many times as you want; just use the same commands to choose another editor or update your email address.
Now that Git is set up, you will be ready to start the Week 2 materials to learn about version control and how Git & GitHub work.
If you have questions or comments on this content, please contact us.