This class uses the command line, so first you will need to find and open your terminal. For Windows, we recommend using Git Shell or Git Bash. For Mac or Linux, your default Terminal will work.
Before you can work with Git on the command line, you will need to set some basic configurations.
- Open your Terminal application.
Ensure Git 1.9.5 or is installed, type:
If your Git version is below 1.9.5, check git-scm.com to download the latest version.
Set your name in Git by replacing
<YOUR NAME>with your first and last name:
git config --global user.name <YOUR NAME>
Set your email in Git by replacing
<EMAIL>with the email associated with your GitHub account.
git config --global user.email <EMAIL>
- Set line-ending behavior for your operating system:
git config --global core.autocrlf true
On Mac and Unix-like systems:
git config --global core.autocrlf input
To see your current configurations, type:
git config --list
Tell me why
Git uses config settings to customize your local working environment based on your preferences. You can do a lot with Git config, but we start with the basics.
Git allows you to set configuration options at three different levels.
--system: These are system-wide configurations. They apply to all users on this computer.
--global: These are the user level configurations. They only apply to your machine’s user account and will be applied to every repository you create or clone under your account.
--local: These are the repository level configurations. They only apply to the specific repository where they are set.
The default value for git config is
--local. The local scope has precedence so setting something at this level will override settings at the global or system level.
If you’re using Git to collaborate with others on GitHub, ensure that Git is properly configured to handle line endings.
Every time you press return on your keyboard you’re actually inserting an invisible character called a line ending. Historically, different operating systems have handled line endings differently.
When you view changes in a file, Git handles line endings in its own way. Since you’re collaborating on projects with Git and GitHub, Git might produce unexpected results if, for example, you’re working on a Windows machine, and your collaborator has made a change in OS X.
For more information about
autocrlf, see the GitHub Help documentation.
Taking Git Config Further
ProGit offers more information on customizing Git with git config.