Using Git with Command Line

To start using Git, we are first going to open up our Command shell.

For Windows, you can use Git Bash, which comes included in Git for Windows. For Mac and Linux, you can use the built-in terminal.

Configure Git

Now let Git know who you are. This is important for version control systems, as each Git commit uses this information:

git config --global user.name "your-username"
git config --global user.email "your-email@example.com"

Change the username and email address to your own. You will probably also want to use this when registering to GitHub later on.

Note: Use --global to set the username and email for every repository on your computer. If you want to set the username/email for just the current repo, you can remove --global.

Creating a Git Folder

Now, let's create a new folder for project: example, Newproject.

mkdir Newproject
cd Newproject
  • mkdir makes a new directory.
  • cd changes the current working directory.

Now that we are in the correct directory, we can start by initializing Git!

Note: If you already have a folder/directory you would like to use for Git, navigate to it in the command line, or open it in your file explorer, right-click and select "Git Bash here".