**This document is a work in progress.**
Use Piazza to suggest further Git tips and tricks we might include.
Before you start using Git, it's a good idea to configure Git to be a little bit nicer.
## Who are you?
Every Git commit has an author, the name and email address of the person who wrote the code.
Especially when working on a team project, you should make sure your Git commits include your correct name and email.
git config --global user.name "Your Name"
git config --global user.email username@mit.edu
## Commit messages
*or, "I do `git commit` and then I can't type!"*
When you run `git commit`, you will be presented with a text editor that lets you edit the descriptive message for that commit.
Unfortunately, Git may choose a default text editor that is unexpected and unintuitive.
### Nano
Unfortunately, [nano](http://www.nano-editor.org) does not come with the Windows version of Git.
Skip ahead to the section on Vim.
Before making your first commit, try running:
nano
in the terminal.
The result should be a simple editor with instructions at the bottom of the screen; quit with `ctrl-X`.
If that worked:
git config --global core.editor nano
will configure Git to use the nano editor.
The commands to use the text editor (like copy, paste, quit, etc.) will be shown on the bottom of the screen.
The `^` symbol represents the `ctrl` key.
For example, you can press `ctrl-O` to save (nano calls it "write out") and then `ctrl-X` to quit.
### Vim
On Windows, if you use Git Bash the default editor will be [Vim](http://www.vim.org).
Vim is another text editor, like nano or notepad.
In order to get started Vim there are only a few commands you must remember.
Before making your first commit, try running:
vim
in the terminal.
You start in a mode called "normal mode".
You can't immediately type anything.
In order to get typing press `i` (stands for insert).
This will bring you to "insert mode", so named because in this mode you can actually type.
When you are done typing press `esc`. This will bring you back to "normal mode".
In order to save your work you want to type `:w` and press return.
And in order to exit vim you want to type `:q` and press return.
Because saving and quitting is a very common action, there is actually a shortcut `:x`, which stands for `:wq` (which just combines `:w` and `:q`).
## Adding some color
Out of the box, it can be hard to see and understand all the output that git prints out at you.
One way to make it a little easier is to add some color.
You can run the following commands to make your git output colorful:
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
git config --global color.grep auto