Lesson Weekend

After installing Git, we recommend a few Git configurations that will make using Git on your own device similar to the experience you will have at Epicodus. These configurations are already set up on the Epicodus machines and will not need to be implemented when in class.

Make VS Code the Default Editor

To make Git use the VS Code text editor to interact with you instead of vim (or whatever your system's default terminal editor may be) run the following two commands:

(For Windows machines, make sure you're running these commands in the git-bash program you installed in this lesson):

$ git config --global core.editor "code --wait"

Configure Color Output

Setting this global configuration will color code Git information in the terminal for easier reading:

$ git config --global color.ui true

Configure Global Author Settings

When working alone on a project, we do not need to use a .pairs file. We do this with a global configuration in the terminal:

$ git config --global user.name "Padma Patil"
$ git config --global user.email "[email protected]"

This sets the name and email for every save that is made in any directory anywhere on the device. If you are setting this on your personal device you will only have to set this once for it to be set on every project.

Ignore files

Once a Git repository is created in your project directory, Git will track every file and folder there, even the ones you may not want included in your project! For example, operating systems often add files without input from you. For example, Macs create hidden files in most directories called .DS_Store. Windows directories often contain files called Thumbs.db.

To ignore these files in all of your Git repositories, you can create an "ignore file" in your home directory with the global tag to indicate this is for every Git repository that is created anywhere on the device.

Here are the steps:

1. Navigate to your home directory:

$ cd ~

2. Create an empty, new file in your home directory called .gitignore_global:

$ touch .gitignore_global

3. Open your new file in VS Code (or you can use an editor in the terminal like Nano or Vim, if you prefer):

$ code .gitignore_global

4. Within the file you've just opened in VS Code, or a Terminal text editor (like Nano or Vim), add rules for the files and file types you want ignored by creating a list. Each kind of file should reside on a new line. (See example below)

At this point, you may not know what files you'd want to ignore globally. That's fine. To get started, copy and paste the list below into your .gitignore_global file (from GitHub's list). This will ensure that pesky files generated by your operating system will not fill up your project folders:

# OS generated files #

As you gain experience with the kinds of files you don't want cluttering your Git repository, you can return to your .gitignore file and add others.

5. Tell Git to use this file as a rule for all of the coding projects you set up on this computer:

$ git config --global core.excludesfile ~/.gitignore_global

One last thing: note that all file names that begin with a . are hidden, so files like .gitignore and .gitignore_global won't be visible either in the GUI (graphical user interface) or with the ls command. Instead, you'll need to use the all flag like this ls -a in order to see these hidden files.