Repository Initialization and Cloning

Create a new local Git repository

git init <project-name>

Clone a Git repository

git clone <url>

Clone a Git repository to a specific local directory

git clone <url> <local-dir>

Configuration

Set identity

git config --global [user.name](<http://user.name>) "Your Name"
git config --global [user.email](<http://user.email>) "[[email protected]](<mailto:[email protected]>)"

Edit Git global configuration

git config --global --edit

Recommended editor, colors, and line endings

# Editor
git config --global core.editor "vim"   # or emacs
# Colors
git config --global color.status auto
git config --global color.branch auto
git config --global color.diff auto
# Line endings
# mac/linux
git config --global core.autocrlf input
# windows
git config --global core.autocrlf true

Global ignore file

touch ~/.gitignore
git config --global core.excludesFile ~/.gitignore

Branch Management

List branches

git branch            # local
git branch -a         # local + remote

Switch and create