How to Set Up Git from the Command Line

5 minutes

Git is an open-source version control system (VCS). In order to use Git to track changes in your code from the command line, you’ll need to download, install and configure it on your computer.

Posted in these interests:
h/git16 guides
h/code69 guides
h/programming8 guides

You can download the program from the Git website for your operating system (Windows, MacOSX, or Linux/Unix).

To install Git directly from the command line, type the following into the terminal (if using Debian-based distributions like Ubuntu):

sudo apt-get install git-all

For MacOS, type:

git --version

and if Git is not already installed, the terminal will prompt you to install it.

Alternatively, if you have HomeBrew installed, you can install Git by typing:

brew install git

Create a Git username by entering the following into the terminal:

git config --global "Jane Doe"

Your name goes in the quotation marks. The --global option means that this will configure your Git username for every repo on your computer. You can also only do this for a single repo.

You can confirm that you have entered your username correctly by typing:

git config --global

which should return your name:

Jane Doe

You can set your email address in Git as well, which is necessary if you plan on committing code to GitHub. Type the following into the terminal:

git config --global ""

Once again to confirm you have entered your email correctly:

git config --global

To create a new Git repository or reinitialize an existing Git repository type git init into the terminal.

For more about Git and documentation, check the Git website. For information on GitHub, such as how to set up a remote, check the GitHub documentation.

John John (304)
2 minutes

This guide will show you how to properly commit and push your work in Git. It is assumed that you have Git installed and that you're currently in a clean master branch.