Setting Up Git
OverviewTeaching: 5 min
Exercises: 0 minQuestions
How do I get set up to use Git?Objectives
gitthe first time it is used on a computer.
Understand the meaning of the
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
verb is what we actually want to do. So here is how
Catsy sets up her new laptop:
$ git config --global user.name "Catsy Cline" $ git config --global user.email "email@example.com" $ git config --global color.ui "auto"
Please use your own name and email address instead of Catsy’s. This user name and email will be associated with your subsequent Git activity, which means that any changes pushed to GitHub, BitBucket, GitLab or another Git host server in a later lesson will include this information.
For these lessons, we will be interacting with
GitHub and so the email address used should be
the same as the one used when setting up your GitHub account. If you
are concerned about privacy, please review GitHub’s instructions for
keeping your email address private. If you elect to use
a private email address with GitHub, then use that same email address
user.email value, e.g.
username with your GitHub one. You can change the email
address later on by using the
git config command again.
You might also want to configure Git to use your favorite text editor, following this table:
|Text Wrangler (Mac)||
|Sublime Text (Mac)||
|Sublime Text (Win, 32-bit install)||
|Sublime Text (Win, 64-bit install)||
|Notepad++ (Win, 32-bit install)||
|Notepad++ (Win, 64-bit install)||
It is possible to reconfigure the text editor for Git whenever you want to change it.
vimis the default editor for for many programs, if you haven’t used
vimbefore and wish to exit a session, type
The four commands we just ran above only need to be run once: the flag
--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.
Finally we need to configure how git will handle line endings in our files.
If you are on a Windows machine, type in the following:
$ git config --global core.autocrlf true
Windows users, please note that you will likely receive the following warning when adding files to git. Don’t worry about this!
"warning: CRLF will be replaced by LF in file."
If you are on a Mac OS/Linux machine, type in the following:
$ git config --global core.autocrlf input
More Windows-specific things you may wish to know
Copying and pasting text to and from the terminal on Windows is done with right-clicking as opposed to the usual
ctrl-vcombo. Right-click highlighted text to copy it (if you’re in the Git bash shell you’ll have to specifically select “Copy”), then right-click and select “Paste” to paste.
In some networks you need to use a proxy. If this is the case, you may also need to tell Git about the proxy:
$ git config --global http.proxy proxy-url $ git config --global https.proxy proxy-url
To disable the proxy, use
$ git config --global --unset http.proxy $ git config --global --unset https.proxy
Git Help and Manual
Always remember that if you forget a
gitcommand, you can access the list of commands and the Git manual by using
$ git help $ git help config
git configto configure a user name, email address, editor, and other preferences once per machine.