# Git


[[TOC]]

Git allows you to do many things with your code:

- Download code from GitHub or other Git repositories
- Commit changes to a local repository
- Push changes to GitHub or other Git repositories
- Keep track of changes to your code so you can easily revert to a previous version
- Collaborate with other developers
- Resolve code conflicts when working with other developers
- Create and manage multiple branches, so your new changes won't affect the main branch until they are ready

## Installation

To install it, [once you have the terminal and Brew installed](./02-QUICKSTART.md), run:

```bash
brew install git
```

## Prepare your folders

A good practice is to keep all of your Git projects under a single folder, for example:

```bash
mkdir -p $HOME/Projects
cd $HOME/Projects
```

Here:

- `**mkdir -p $HOME/Projects**` means:
  - Create a folder (`mkdir` means "_make directory_")
  - If the folder doesn't exist, create it (`-p` means "_parent directory_")
  - `HOME` is a variable that points to your user's home directory
  - After issuing the command, open the file explorer and make sure the folder is there

- `**cd $HOME/Projects**` means:
  - Change directory (`cd` means "_change directory_")
  - `HOME` is a variable that points to your user's home directory
  - After issuing this command, your terminal is inside of your new folder, and any file you create will be created in there

Instead of `$HOME`, you can also use `~` to refer to your home directory, e.g.:

```bash
mkdir -p ~/Projects
cd ~/Projects
```

## Create your accounts

### Github

Github is the most popular Git service, used by most of the world's software developers.

- [Create a new account](https://github.com/join)
- [Follow me 🙂](https://github.com/blacklight)

You can follow other developers, see their projects, follow their updates, "fork" other projects (i.e. make your own versions with your modifications), and once you have enough experience also submit your modifications to other projects.

### Our personal Git server

This is the Git server where I keep most of my personal projects, and we can use it to share private projects without cluttering our public Github profiles 🙂

- Go to [git.platypush.tech](https://git.platypush.tech)
- Select _Sign In_ in the top right corner
- Select _Sign in with Platypush SSO_
- Select _Sign in with Github_ - your Github account will be linked to this account

